我试图将django与芹菜一起使用celerybeat运行定期任务。我将ced进程设置为systemd
[Unit]
Description=my celery daemon
After=network.target
[Service]
PIDFile=/var/run/celery/celery.pid
Type=forking
User=myuser
Group=www-data
RuntimeDirectory=celery
RuntimeDirectoryMode=0770
WorkingDirectory=/opt/myapp/
ExecStart=/opt/myapp/.virtualenv/bin/celery multi start worker1 \
--app=myapp \
--concurrency=1 \
--schedule=/var/run/celery/celerybeat-schedule \
--pidfile=/var/run/celery/celery.pid \
--logfile=/opt/myapp/log/celery.log \
--loglevel=INFO \
--beat
ExecStop=/opt/myapp/.virtualenv/bin/celery multi stopwait worker1 \
--pidfile=/var/run/celery/celery.pid \
--logfile=/opt/myapp/log/celery.log \
ExecReload=/opt/myapp/.virtualenv/bin/celery multi restart worker1 \
--pidfile=/var/run/celery/celery.pid \
--logfile=/opt/myapp/log/celery.log \
[Install]
WantedBy=multi-user.target
这一切都运行良好..但我注意到它产生3/4进程,尽管只有1个worker,并发设置为1.为什么这个?我的目标是让一名工作人员运行,将任务排队,而不是暂时同步执行。
$ ps aux | grep celery
:
myuser 1748 0.6 11.8 189816 59400 ? S 11:59 0:01 /opt/myapp/.virtualenv/bin/python -m celery worker --beat --concurrency=1 --app=myapp --schedule=/var/run/celery/celerybeat-schedule --loglevel=INFO --logfile=/opt/myapp/log/celery.log --pidfile=/var/run/celery/celery.pid --hostname=worker1@staging
myuser 1753 1.2 11.9 272324 59528 ? Sl 11:59 0:02 /opt/myapp/.virtualenv/bin/python -m celery worker --beat --concurrency=1 --app=myapp --schedule=/var/run/celery/celerybeat-schedule --loglevel=INFO --logfile=/opt/myapp/log/celery.log --pidfile=/var/run/celery/celery.pid --hostname=worker1@staging
myuser 1754 0.0 11.4 197540 57244 ? S 11:59 0:00 /opt/myapp/.virtualenv/bin/python -m celery worker --beat --concurrency=1 --app=myapp --schedule=/var/run/celery/celerybeat-schedule --loglevel=INFO --logfile=/opt/myapp/log/celery.log --pidfile=/var/run/celery/celery.pid --hostname=worker1@staging