From 08bd696434efe7eea0308330f1d1606757db0bb7 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Wed, 24 Oct 2018 22:08:30 +0200 Subject: [PATCH] Fix celery behavior --- conf/celery-weblate | 7 ++----- conf/celery-weblate.service | 17 ++++++++++------- .../{settings.3.2.py => settings.3.2.2.py} | 4 ++-- manifest.json | 2 +- scripts/_common.sh | 2 +- scripts/backup | 6 ------ scripts/install | 6 ++---- scripts/remove | 5 ++--- scripts/restore | 7 ------- 9 files changed, 20 insertions(+), 36 deletions(-) rename conf/settings_history/{settings.3.2.py => settings.3.2.2.py} (99%) diff --git a/conf/celery-weblate b/conf/celery-weblate index b1b3091..fc28813 100644 --- a/conf/celery-weblate +++ b/conf/celery-weblate @@ -4,9 +4,6 @@ CELERYD_NODES="w1" # or we could have three nodes: #CELERYD_NODES="w1 w2 w3" -# Absolute or relative path to the 'celery' command: -CELERY_BIN="/usr/bin/celery" - # App instance to use # comment out this line if you don't use an app CELERY_APP="weblate" @@ -20,8 +17,8 @@ CELERYD_OPTS="--beat" # - %n will be replaced with the first part of the nodename. # - %I will be replaced with the current child process index # and is important when using the prefork pool to avoid race conditions. -CELERYD_PID_FILE="/var/run/celery-__APP__/weblate-%n.pid" -CELERYD_LOG_FILE="/var/log/uwsgi/app/__APP__-celery-%n%I.log" +CELERYD_PID_FILE="/var/run/__APP__-celery/weblate-%n.pid" +CELERYD_LOG_FILE="/var/log/__APP__-celery/celery-%n%I.log" CELERYD_LOG_LEVEL="INFO" CELERY_WORKER_RUNNING="1" \ No newline at end of file diff --git a/conf/celery-weblate.service b/conf/celery-weblate.service index 59e566e..87be424 100644 --- a/conf/celery-weblate.service +++ b/conf/celery-weblate.service @@ -8,16 +8,19 @@ User=__APP__ Group=__APP__ PermissionsStartOnly=true EnvironmentFile=__FINALPATH__/celery-weblate -Environment=PATH=__FINALPATH__/venv/bin:$PATH 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} \ - --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}' -ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES} \ - --pidfile=${CELERYD_PID_FILE}' -ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} \ + --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS} +ExecStop=__FINALPATH__/venv/bin/celery multi stopwait ${CELERYD_NODES} \ + --pidfile=${CELERYD_PID_FILE} +ExecReload=__FINALPATH__/venv/bin/celery multi restart ${CELERYD_NODES} \ -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] WantedBy=multi-user.target \ No newline at end of file diff --git a/conf/settings_history/settings.3.2.py b/conf/settings_history/settings.3.2.2.py similarity index 99% rename from conf/settings_history/settings.3.2.py rename to conf/settings_history/settings.3.2.2.py index d614042..ffbe881 100644 --- a/conf/settings_history/settings.3.2.py +++ b/conf/settings_history/settings.3.2.2.py @@ -716,7 +716,7 @@ ALLOWED_HOSTS = ['__DOMAIN__'] CACHES = { 'default': { 'BACKEND': 'django_redis.cache.RedisCache', - 'LOCATION': 'redis://127.0.0.1:6379/_REDIS_DB__', + 'LOCATION': 'redis://127.0.0.1:6379/__REDIS_DB__', 'OPTIONS': { 'CLIENT_CLASS': 'django_redis.client.DefaultClient', 'PARSER_CLASS': 'redis.connection.HiredisParser', @@ -814,7 +814,7 @@ REST_FRAMEWORK = { # CELERY_BROKER_URL = 'memory://' # Celery worker configuration for production 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_WORKER_PREFETCH_MULTIPLIER = 0 diff --git a/manifest.json b/manifest.json index 739fb0d..eeee946 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "description": { "en": "A translation platform using Git and Python" }, - "version": "3.2~ynh1", + "version": "3.2.2~ynh1", "url": "https://weblate.org", "license": "AGPL-3.0", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 2c5e87c..e6bff98 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,6 +1,6 @@ #!/bin/bash -current_version="3.2" +current_version="3.2.2" ynh_check_global_uwsgi_config () { uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency" diff --git a/scripts/backup b/scripts/backup index 3578fbe..e159b99 100755 --- a/scripts/backup +++ b/scripts/backup @@ -56,12 +56,6 @@ ynh_backup "db.sql" ynh_backup "/etc/cron.d/$app" -#================================================= -# BACKUP THE CRON FILE -#================================================= - -ynh_backup "/usr/lib/tmpfiles.d/$app.conf" - #================================================= # BACKUP THE uwsgi files #================================================= diff --git a/scripts/install b/scripts/install index d382546..c6236b8 100755 --- a/scripts/install +++ b/scripts/install @@ -257,10 +257,8 @@ ynh_store_file_checksum "$final_path/venv/lib/python3.5/site-packages/weblate/se celeryconf="$final_path/celery-weblate" cp ../conf/celery-weblate "$celeryconf" -ynh_replace_string "__APP__" "$app" "$celeryconf" - -echo "d /var/run/celery-$app 0775 $app $app" > "/usr/lib/tmpfiles.d/$app.conf" -systemd-tmpfiles --create +ynh_replace_string "__APP__" "$app" "$celeryconf" +ynh_replace_string "__FINALPATH__" "$final_path" "$celeryconf" ynh_add_systemd_config "$app-celery" "celery-weblate.service" diff --git a/scripts/remove b/scripts/remove index 6adfad6..b341da1 100755 --- a/scripts/remove +++ b/scripts/remove @@ -62,11 +62,10 @@ ynh_remove_nginx_config ynh_secure_remove "/etc/cron.d/$app" #================================================= -# REMOVE TMPFILES.D +# REMOVE CELERY FILES #================================================= -ynh_secure_remove "/var/run/celery-$app" -ynh_secure_remove "/usr/lib/tmpfiles.d/$app.conf" +ynh_secure_remove "/var/run/$app-celery" #================================================= # REMOVE uwsgi and systemd files diff --git a/scripts/restore b/scripts/restore index ae0ea38..d42fc52 100755 --- a/scripts/restore +++ b/scripts/restore @@ -123,13 +123,6 @@ yunohost service add "uwsgi-app@$app.service" --log "/var/log/uwsgi/app/$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 #=================================================