django - 芹菜不作为守护进程工作
问题描述
我正在尝试使用 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
请让我知道如何将芹菜作为守护进程运行。
解决方案
推荐阅读
- python - 如何选择价值?
- c# - 如何使用带有主应用程序的 OpenTelemetry 在任何数据库中保存行跟踪数据
- sql - Oracle SQL根据其他列的值添加新列
- c# - 如何使用 C# 中的指针安全地清除 TextBox 的内容?
- s-expression - 查询以选择没有给定属性的 html 标记
- css - TailwindCSS FontAwesome svg 图标未对齐
- python - 通过引用传递时验证python列表中完全相同的变量
- python-3.x - Python twint 库在 Colab 环境中不起作用
- javascript - 重复传单上的重复折线映射低级别的缩放
- mysql - MariaDB:选择所有字段,但修改了一个字段