我试图在Centos 7上运行芹菜守护进程,它有systemd / systemctl。它不起作用。
有什么建议可以解决吗?
下面是我的守护进程默认配置:
CELERYD_NODES="localhost.localdomain"
CELERY_BIN="/tmp/myapp/venv/bin/celery"
CELERY_APP="pipeline"
CELERYD_OPTS="--broker=amqp://192.168.168.111/"
CELERYD_LOG_LEVEL="INFO"
CELERYD_CHDIR="/tmp/myapp"
CELERYD_USER="root"注意:我正在启动守护进程
sudo /etc/init.d/celeryd start我的芹菜守护程序脚本来自:https://raw.githubusercontent.com/celery/celery/3.1/extra/generic-init.d/celeryd
我也尝试过from:https://raw.githubusercontent.com/celery/celery/3.1/extra/generic-init.d/celeryd,但是这个尝试启动守护进程时显示了一个错误:
systemd[1]: Starting LSB: celery task worker daemon...
celeryd[19924]: basename: missing operand
celeryd[19924]: Try 'basename --help' for more information.
celeryd[19924]: Starting : /etc/rc.d/init.d/celeryd: line 193: multi: command not found
celeryd[19924]: [FAILED]
systemd[1]: celeryd.service: control process exited, code=exited status=1
systemd[1]: Failed to start LSB: celery task worker daemon.
systemd[1]: Unit celeryd.service entered failed state.发布于 2015-05-09 06:01:55
发布于 2016-09-22 22:08:42
正如@ChillarAnand之前回答的那样,不要使用celeryd。
但实际上,它并不像他所写的那样简单,用systemd与celery multi一起运行芹菜。
这是我的工作,不明显(我认为)的例子。
他们在Centos 7.1.1503上进行了测试,芹菜3.1.23 (Cipater)在virtualenv中运行,tasks.py示例应用程序来自芹菜教程。
经营一名工人
[Unit]
Description=Celery Service
After=network.target
[Service]
Type=forking
User=vagrant
Group=vagrant
# directory with tasks.py
WorkingDirectory=/home/vagrant/celery_example
# !!! using the below systemd is REQUIRED in this case!
# (you will still get a warning "PID file /var/run/celery/single.pid not readable (yet?) after start." from systemd but service will in fact be starting, stopping and restarting properly. I haven't found a way to get rid of this warning.)
PIDFile=/var/run/celery/single.pid
# !!! using --pidfile option here and below is REQUIRED in this case!
# !!! also: don't use "%n" in pidfile or logfile paths - you will get these files named after the systemd service instead of after the worker (?)
ExecStart=/home/vagrant/celery_example/venv/bin/celery multi start single-worker -A tasks --pidfile=/var/run/celery/single.pid --logfile=/var/log/celery/single.log "-c 4 -Q celery -l INFO"
ExecStop=/home/vagrant/celery_example/venv/bin/celery multi stopwait single-worker --pidfile=/var/run/celery/single.pid --logfile=/var/log/celery/single.log
ExecReload=/home/vagrant/celery_example/venv/bin/celery multi restart single-worker --pidfile=/var/run/celery/single.pid --logfile=/var/log/celery/single.log
# Creates /var/run/celery, if it doesn't exist
RuntimeDirectory=celery
[Install]
WantedBy=multi-user.target运行多个工人
[Unit]
Description=Celery Service
After=network.target
[Service]
Type=forking
User=vagrant
Group=vagrant
# directory with tasks.py
WorkingDirectory=/home/vagrant/celery_example
# !!! in this case DON'T set PIDFile or use --pidfile or --logfile below or it won't work!
ExecStart=/home/vagrant/celery_example/venv/bin/celery multi start 3 -A tasks "-c 4 -Q celery -l INFO"
ExecStop=/home/vagrant/celery_example/venv/bin/celery multi stopwait 3
ExecReload=/home/vagrant/celery_example/venv/bin/celery multi restart 3
# Creates /var/run/celery, if it doesn't exist
RuntimeDirectory=celery
[Install]
WantedBy=multi-user.target(请注意,我运行的工作人员的-c / --concurrency >1,但它也与它的设置为1或默认值。此外,如果您不使用virtualenv,这也是可行的,但我强烈建议您使用它。)
我真的不明白为什么systemd在第一种情况下不能猜测分叉进程的PID,以及为什么将pidfiles放在特定位置会破坏第二种情况,所以我在这里提交了一张罚单:https://github.com/celery/celery/issues/3459。如果我能得到答案或者自己想出一些解释,我就会把它们发到这里。
https://stackoverflow.com/questions/30133170
复制相似问题