我正在尝试使用django和celery来自动化任务并想要 将celery作为守护程序运行。我复制了celeryd和 celerybeat的官方文档,并将其放入 /etc/init.d/文件夹。
下面是我的celeryd文件的代码,我将其放在“ etc / default”文件夹中。粗体字母的代码为带注释的代码。
CELERY_BIN="/home/user/.local/bin/celery"
# Name of nodes to start, here we have a single node
CELERYD_NODES="worker"
# or we could have three nodes:
#CELERYD_NODES="w1 w2 w3"
# Where to chdir at start.
CELERYD_CHDIR="/home/user/django_project"
CELERY_APP="django_project"
#How to call "manage.py celeryd_multi"
#CELERYD_MULTI="$CELERYD_CHDIR/django_project/manage.py celeryd_multi"
# Extra arguments to celeryd
#CELERYD_OPTS="--time-limit 300 --concurrency=8"
# Name of the celery config module.
CELERY_CONFIG_MODULE="celeryconfig"
# %n will be replaced with the nodename.
CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"
# Workers should run as an unprivileged user.
CELERYD_USER="user"
CELERYD_GROUP="user"
# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE="settings"
# beat settings
CELERYBEAT_OPTS="--scheduler django_celery_beat.schedulers:DatabaseScheduler"
CELERYBEAT_LOG_FILE="/var/log/celery/celeryBeat.log"
CELERYBEAT_PID_FILE="/var/run/celery/celeryBeat.pid"
# If enabled pid and log directories will be created if missing,
# and owned by the userid/group configured.
CELERY_CREATE_DIRS=1
我使用“ sudo /etc/init.d/celeryd/ start”命令启动了celeryd。
我使用“ sudo /etc/init.d/celerybeat/ start”命令启动了celerybeat。
当我检查celery和celerybeat的状态时,它会显示
celery init v10.1.
Using config script: /etc/default/celeryd
celeryd down: no pidfiles found
请让我知道如何将celery作为守护程序运行。