将celery作为守护程序运行不会创建PID文件

时间:2023-01-31 16:54:38

I have been scratching my brains on this one since past few days, I have seen other issues on * (as it is a duplicate question) and I have tried everything to make this work, the workers are running fine but the celery is not starting up as a process.

这几天我一直在绞尽脑汁,我已经看到了*上的其他问题(因为它是一个重复的问题)而且我已经尝试了一切来使这项工作,工人运行良好,但芹菜没有开始作为一个过程。

I run the command:

我运行命令:

sudo service celeryd start

and I get:

我得到:

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

I run:

sudo service celeryd status

and I get:

我得到:

celery init v10.1.
Using config script: /etc/default/celeryd
celeryd down: no pidfiles found

The celeryd down: no pidfiles found error is what I need to resolve.

celeryd down:没有发现pidfiles错误是我需要解决的问题。

I know this question is a duplicate one but still go along with me on this one because I have tried all of them and still unable to get it resolved.

我知道这个问题是重复的,但在这个问题上仍然跟我一起,因为我已经尝试了所有这些,但仍然无法解决问题。

I am deploying this script on Amazon Web Services. I am using a virtual environment.

我正在Amazon Web Services上部署此脚本。我正在使用虚拟环境。

The init.d script is taken directly from the here and then I gave it the required permissions.

init.d脚本直接从这里获取,然后我给了它所需的权限。

Here is my configuration file:

这是我的配置文件:

# 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

I have used the process to create the celery user using this article.

我已经使用该过程来使用本文创建芹菜用户。

My project is a Django project and I have specified the DJANGO_SETTINGS_MODULE environment variable in the celery setting file as specified in the documentation and also in the * answer.

我的项目是一个Django项目,我在celery设置文件中指定了DJANGO_SETTINGS_MODULE环境变量,如文档和*答案中所指定的那样。

Do I need to change anything in the init.d script or anything else that needs to be added in the celery configuration file... Is it about the celery user that I have created because I also tried specifying

我是否需要更改init.d脚本中的任何内容或需要在celery配置文件中添加的任何其他内容...是否是我创建的芹菜用户,因为我也尝试过指定

CELERYD_USER = ""
CELERYD_GROUP = ""

while also changing the DEFAULT_USER value to "" in the init.d script. Still the issue persisted.

同时还在init.d脚本中将DEFAULT_USER值更改为“”。问题仍然存在。

In one of the answers it was also told that there might be some errors in the project... but I did not find any such errors all thanks to my test cases.

在其中一个答案中,它还被告知项目中可能存在一些错误......但由于我的测试用例,我没有发现任何此类错误。

PS : I have specified , and for privacy issues they have their original names.

PS:我已经指定,并且出于隐私问题,他们有自己的原始名称。

2 个解决方案

#1


1  

I had the issue and solved it just now, thank god! For me it was a permission issue. I had expected it to be in /var/run/celery or /var/log/celery but it turns out it was the log file I have setup Django logging for. For some reason celery wanted to write to that file (I have to look into that) but had no permission. I found the error with the verbose command and skip daemonization step:

我有问题并且刚才解决了,谢天谢地!对我来说这是一个许可问题。我曾预料它会在/ var / run / celery或/ var / log / celery中,但事实证明这是我设置Django的日志文件。出于某种原因,芹菜想要写入该文件(我必须查看)但没有许可。我在verbose命令中找到了错误并跳过了daemonization步骤:

# C_FAKEFORK=1 sh -x /etc/init.d/celeryd start 

This is an old thread but if anyone of you run into this error, I hope this may help!

这是一个旧线程,但如果你有人遇到这个错误,我希望这可能会有所帮助!

Good luck!

#2


0  

I saw the same issue and it turned out to be a permissions issue. Make sure to set the user/group that celery is running under to own the /var/log/celery/ and /var/run/celery/ folders. See here for a step by step example: Daemonizing celery

我看到了同样的问题,结果证明是权限问题。确保将芹菜运行的用户/组设置为拥有/ var / log / celery /和/ var / run / celery / folders。请看这里的分步示例:Daemonizing芹菜

#1


1  

I had the issue and solved it just now, thank god! For me it was a permission issue. I had expected it to be in /var/run/celery or /var/log/celery but it turns out it was the log file I have setup Django logging for. For some reason celery wanted to write to that file (I have to look into that) but had no permission. I found the error with the verbose command and skip daemonization step:

我有问题并且刚才解决了,谢天谢地!对我来说这是一个许可问题。我曾预料它会在/ var / run / celery或/ var / log / celery中,但事实证明这是我设置Django的日志文件。出于某种原因,芹菜想要写入该文件(我必须查看)但没有许可。我在verbose命令中找到了错误并跳过了daemonization步骤:

# C_FAKEFORK=1 sh -x /etc/init.d/celeryd start 

This is an old thread but if anyone of you run into this error, I hope this may help!

这是一个旧线程,但如果你有人遇到这个错误,我希望这可能会有所帮助!

Good luck!

#2


0  

I saw the same issue and it turned out to be a permissions issue. Make sure to set the user/group that celery is running under to own the /var/log/celery/ and /var/run/celery/ folders. See here for a step by step example: Daemonizing celery

我看到了同样的问题,结果证明是权限问题。确保将芹菜运行的用户/组设置为拥有/ var / log / celery /和/ var / run / celery / folders。请看这里的分步示例:Daemonizing芹菜