Celery: Systemd:重新加载芹菜可以将其干净地关闭,但不会重新启动

创建于 2017-11-15  ·  3评论  ·  资料来源: celery/celery

检查清单

  • [x]我已验证Celery的master分支存在此问题。
  • [x]我已将celery -A proj report的输出包含在该问题中:
software -> celery:4.1.0 (latentcall) kombu:4.1.0 py:3.5.2
            billiard:3.5.0.3 redis:2.10.6
platform -> system:Linux arch:64bit, ELF imp:CPython
loader   -> celery.loaders.app.AppLoader
settings -> transport:redis results:disabled

CACHES: {
    'default': {   'BACKEND': 'django_redis.cache.RedisCache',
                   'LOCATION': 'redis://localhost:6379/1',
                   'TIMEOUT': 3600}}

CELERY_TASK_COMPRESSION: 'gzip'
CELERY_TASK_IGNORE_RESULT: True
CELERY_ACCEPT_CONTENT: ['pickle', 'json', 'msgpack', 'yaml']
CELERY_BROKER_URL: 'redis://localhost:6379/0'

DEBUG: False
INSTALLED_APPS:
    ('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.admin',
 'django.contrib.sitemaps',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'django.contrib.redirects',
 'django.contrib.gis',

 'django_extensions',
)

重现步骤

在Ubuntu 16.04上。

  1. 根据celery文档通过systemd设置celery
  2. 通过sudo service <your-celery-service-name> start开始芹菜
  3. 尝试通过sudo service <your-celery-service-name> reload重新加载芹菜

预期行为

芹菜应该优雅地装满。

实际行为

芹菜不会优雅地重新加载。 它会关闭,但永远不会重新启动。

发出重新加载请求(以及随后的启动失败)之后, sudo journalctl -xe的输出似乎没有显示出任何恶意:

Nov 15 04:33:04 ip-172-31-44-219 sudo[12972]:   ubuntu : TTY=pts/0 ; PWD=/home/ubuntu ; USER=root ; COMMAND=/usr/sbin/service myproj-celery reload
Nov 15 04:33:04 ip-172-31-44-219 sudo[12972]: pam_unix(sudo:session): session opened for user root by ubuntu(uid=0)
Nov 15 04:33:04 ip-172-31-44-219 systemd[1]: Reloading myproj celery worker.
-- Subject: Unit myproj-celery.service has begun reloading its configuration
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit myproj-celery.service has begun reloading its configuration
Nov 15 04:33:07 ip-172-31-44-219 sh[12979]: celery multi v4.1.0 (latentcall)
Nov 15 04:33:07 ip-172-31-44-219 sh[12979]: > Stopping nodes...
Nov 15 04:33:07 ip-172-31-44-219 sh[12979]:         > worker1@ip-172-31-44-219: TERM -> 12962
Nov 15 04:33:07 ip-172-31-44-219 sh[12979]: > Waiting for 1 node -> 12962.....
Nov 15 04:33:07 ip-172-31-44-219 sh[12979]:         > worker1@ip-172-31-44-219: OK
Nov 15 04:33:07 ip-172-31-44-219 sh[12979]: > Restarting node worker1@ip-172-31-44-219: OK
Nov 15 04:33:07 ip-172-31-44-219 sh[12979]: > Waiting for 1 node -> None...
Nov 15 04:33:07 ip-172-31-44-219 sh[12992]: celery multi v4.1.0 (latentcall)
Nov 15 04:33:07 ip-172-31-44-219 sh[12992]: > worker1@ip-172-31-44-219: DOWN
Nov 15 04:33:07 ip-172-31-44-219 systemd[1]: Reloaded myproj celery worker.
-- Subject: Unit myproj-celery.service has finished reloading its configuration
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit myproj-celery.service has finished reloading its configuration
--
-- The result is done.
Nov 15 04:33:07 ip-172-31-44-219 sudo[12972]: pam_unix(sudo:session): session closed for user root

也许CELERYD_PID_FILE="/var/run/celery/%N.pid"不知道是问题所在吗? 意思是,我们不能(通过PIDFile= )告诉Systemd PID文件的实际位置是什么,因为它是由芹菜本身生成的,不是吗?

Deployment Bug Report

最有用的评论

有同样的问题。
我通过编辑systemd config来解决它。
重启=总是

所有3条评论

您能张贴您的systemd和celery文件吗?
您可以告诉systemd PID的存储位置,但必须对其进行转义:

celery multi restart w1 -A proj --pidfile=/tmp/celery_%%n.pid

注意双百分数。

有同样的问题。
我通过编辑systemd config来解决它。
重启=总是

此页面是否有帮助?
0 / 5 - 0 等级