1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/weblate_ynh.git synced 2024-10-01 13:35:04 +02:00

Fix celery behavior

This commit is contained in:
Jean-Baptiste Holcroft 2018-10-24 22:08:30 +02:00
parent 9cf6fd0e89
commit 08bd696434
9 changed files with 20 additions and 36 deletions

View file

@ -4,9 +4,6 @@ CELERYD_NODES="w1"
# or we could have three nodes: # or we could have three nodes:
#CELERYD_NODES="w1 w2 w3" #CELERYD_NODES="w1 w2 w3"
# Absolute or relative path to the 'celery' command:
CELERY_BIN="/usr/bin/celery"
# App instance to use # App instance to use
# comment out this line if you don't use an app # comment out this line if you don't use an app
CELERY_APP="weblate" CELERY_APP="weblate"
@ -20,8 +17,8 @@ CELERYD_OPTS="--beat"
# - %n will be replaced with the first part of the nodename. # - %n will be replaced with the first part of the nodename.
# - %I will be replaced with the current child process index # - %I will be replaced with the current child process index
# and is important when using the prefork pool to avoid race conditions. # and is important when using the prefork pool to avoid race conditions.
CELERYD_PID_FILE="/var/run/celery-__APP__/weblate-%n.pid" CELERYD_PID_FILE="/var/run/__APP__-celery/weblate-%n.pid"
CELERYD_LOG_FILE="/var/log/uwsgi/app/__APP__-celery-%n%I.log" CELERYD_LOG_FILE="/var/log/__APP__-celery/celery-%n%I.log"
CELERYD_LOG_LEVEL="INFO" CELERYD_LOG_LEVEL="INFO"
CELERY_WORKER_RUNNING="1" CELERY_WORKER_RUNNING="1"

View file

@ -8,16 +8,19 @@ User=__APP__
Group=__APP__ Group=__APP__
PermissionsStartOnly=true PermissionsStartOnly=true
EnvironmentFile=__FINALPATH__/celery-weblate EnvironmentFile=__FINALPATH__/celery-weblate
Environment=PATH=__FINALPATH__/venv/bin:$PATH
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__FINALPATH__/
ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \ ExecStartPre=/bin/mkdir -p /var/run/__APP__-celery
ExecStartPre=/bin/chown -R __APP__ /var/run/__APP__-celery
ExecStartPre=/bin/mkdir -p /var/log/__APP__-celery
ExecStartPre=/bin/chown -R __APP__ /var/log/__APP__-celery
ExecStart=__FINALPATH__/venv/bin/celery multi start ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \ -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}' --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}
ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES} \ ExecStop=__FINALPATH__/venv/bin/celery multi stopwait ${CELERYD_NODES} \
--pidfile=${CELERYD_PID_FILE}' --pidfile=${CELERYD_PID_FILE}
ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} \ ExecReload=__FINALPATH__/venv/bin/celery multi restart ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \ -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}' --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -716,7 +716,7 @@ ALLOWED_HOSTS = ['__DOMAIN__']
CACHES = { CACHES = {
'default': { 'default': {
'BACKEND': 'django_redis.cache.RedisCache', 'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': 'redis://127.0.0.1:6379/_REDIS_DB__', 'LOCATION': 'redis://127.0.0.1:6379/__REDIS_DB__',
'OPTIONS': { 'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient', 'CLIENT_CLASS': 'django_redis.client.DefaultClient',
'PARSER_CLASS': 'redis.connection.HiredisParser', 'PARSER_CLASS': 'redis.connection.HiredisParser',
@ -814,7 +814,7 @@ REST_FRAMEWORK = {
# CELERY_BROKER_URL = 'memory://' # CELERY_BROKER_URL = 'memory://'
# Celery worker configuration for production # Celery worker configuration for production
CELERY_TASK_ALWAYS_EAGER = False CELERY_TASK_ALWAYS_EAGER = False
CELERY_BROKER_URL = 'redis://localhost:6379/__REDIS_DB__' CELERY_BROKER_URL = 'redis://127.0.0.1:6379/__REDIS_DB__'
# Celery settings, it is not recommended to change these # Celery settings, it is not recommended to change these
CELERY_WORKER_PREFETCH_MULTIPLIER = 0 CELERY_WORKER_PREFETCH_MULTIPLIER = 0

View file

@ -8,7 +8,7 @@
"description": { "description": {
"en": "A translation platform using Git and Python" "en": "A translation platform using Git and Python"
}, },
"version": "3.2~ynh1", "version": "3.2.2~ynh1",
"url": "https://weblate.org", "url": "https://weblate.org",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"maintainer": { "maintainer": {

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
current_version="3.2" current_version="3.2.2"
ynh_check_global_uwsgi_config () { ynh_check_global_uwsgi_config () {
uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency" uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency"

View file

@ -56,12 +56,6 @@ ynh_backup "db.sql"
ynh_backup "/etc/cron.d/$app" ynh_backup "/etc/cron.d/$app"
#=================================================
# BACKUP THE CRON FILE
#=================================================
ynh_backup "/usr/lib/tmpfiles.d/$app.conf"
#================================================= #=================================================
# BACKUP THE uwsgi files # BACKUP THE uwsgi files
#================================================= #=================================================

View file

@ -257,10 +257,8 @@ ynh_store_file_checksum "$final_path/venv/lib/python3.5/site-packages/weblate/se
celeryconf="$final_path/celery-weblate" celeryconf="$final_path/celery-weblate"
cp ../conf/celery-weblate "$celeryconf" cp ../conf/celery-weblate "$celeryconf"
ynh_replace_string "__APP__" "$app" "$celeryconf" ynh_replace_string "__APP__" "$app" "$celeryconf"
ynh_replace_string "__FINALPATH__" "$final_path" "$celeryconf"
echo "d /var/run/celery-$app 0775 $app $app" > "/usr/lib/tmpfiles.d/$app.conf"
systemd-tmpfiles --create
ynh_add_systemd_config "$app-celery" "celery-weblate.service" ynh_add_systemd_config "$app-celery" "celery-weblate.service"

View file

@ -62,11 +62,10 @@ ynh_remove_nginx_config
ynh_secure_remove "/etc/cron.d/$app" ynh_secure_remove "/etc/cron.d/$app"
#================================================= #=================================================
# REMOVE TMPFILES.D # REMOVE CELERY FILES
#================================================= #=================================================
ynh_secure_remove "/var/run/celery-$app" ynh_secure_remove "/var/run/$app-celery"
ynh_secure_remove "/usr/lib/tmpfiles.d/$app.conf"
#================================================= #=================================================
# REMOVE uwsgi and systemd files # REMOVE uwsgi and systemd files

View file

@ -123,13 +123,6 @@ yunohost service add "uwsgi-app@$app.service" --log "/var/log/uwsgi/app/$app"
ynh_restore_file "/etc/cron.d/$app" ynh_restore_file "/etc/cron.d/$app"
#=================================================
# RESTORE THE TMPFILES.D
#=================================================
ynh_restore_file "/usr/lib/tmpfiles.d/$app.conf"
systemd-tmpfiles --create
#================================================= #=================================================
# RESTORE THE HUB BINARY FILE # RESTORE THE HUB BINARY FILE
#================================================= #=================================================