【发布时间】:2016-10-01 19:42:07
【问题描述】:
自从过去几天以来,我一直在为此绞尽脑汁,我在 stackoverflow 上看到了其他问题(因为这是一个重复的问题),我已经尝试了一切来完成这项工作,工人们运行良好,但 celery没有作为一个进程启动。
我运行命令:
sudo service celeryd start
我得到:
celery init v10.1.
Using config script: /etc/default/celeryd
celery multi v3.1.23 (Cipater)
> Starting nodes...
> worker1@ip-172-31-21-215: OK
我跑:
sudo service celeryd status
我得到:
celery init v10.1.
Using config script: /etc/default/celeryd
celeryd down: no pidfiles found
celeryd down: no pidfiles found 错误是我需要解决的。
我知道这个问题是重复的,但我仍然同意这个问题,因为我已经尝试了所有这些问题,但仍然无法解决。
我正在亚马逊网络服务上部署这个脚本。我正在使用虚拟环境。
init.d 脚本直接取自 here,然后我给了它所需的权限。
这是我的配置文件:
# Names of nodes to start
# most people will only start one node:
CELERYD_NODES="worker1"
# but you can also start multiple and configure settings
# for each in CELERYD_OPTS (see `celery multi --help` for examples):
#CELERYD_NODES="worker1 worker2 worker3"
# alternatively, you can specify the number of nodes to start:
#CELERYD_NODES=10
# Absolute or relative path to the 'celery' command:
# CELERY_BIN="/usr/local/bin/celery"
CELERY_BIN="/home/<user>/.virtualenvs/<virtualenv_name>/bin/celery"
# App instance to use
# comment out this line if you don't use an app
# CELERY_APP="proj"
# or fully qualified:
CELERY_APP="<project_name>.settings:app"
# Where to chdir at start.
CELERYD_CHDIR="/home/<user>/projects/<project_name>/"
# Extra command-line arguments to the worker
CELERYD_OPTS="--time-limit=300 --concurrency=8"
# %N will be replaced with the first part of the nodename.
CELERYD_LOG_FILE="/var/log/celery/%N.log"
CELERYD_PID_FILE="/var/run/celery/%N.pid"
# Workers should run as an unprivileged user.
# You need to create this user manually (or you can choose
# a user/group combination that already exists, e.g. nobody).
CELERYD_USER="celery"
CELERYD_GROUP="celery"
# If enabled pid and log directories will be created if missing,
# and owned by the userid/group configured.
CELERY_CREATE_DIRS=1
我已经使用this文章创建了celery用户。
我的项目是一个 Django 项目,我在 celery 设置文件中指定了 DJANGO_SETTINGS_MODULE 环境变量,如 documentation 和 stackoverflow answer 中指定的那样。
我是否需要更改 init.d 脚本中的任何内容或需要在 celery 配置文件中添加的任何其他内容...是否与我创建的 celery 用户有关,因为我也尝试指定
CELERYD_USER = ""
CELERYD_GROUP = ""
同时在init.d 脚本中将DEFAULT_USER 的值更改为“”。
问题仍然存在。
在其中一个答案中还被告知项目中可能存在一些错误......但是由于我的测试用例,我没有发现任何此类错误。
PS:我已经指定了,为了隐私问题 他们有他们原来的名字。
【问题讨论】:
-
我也遇到了同样的问题。有时似乎遵循文档会将您带到这里。
-
在我的虚拟环境中从
4.1和4.2更新我的芹菜版本似乎已经解决了这个问题。