作为守护程序运行celery不会创建PID文件 [英] Running celery as daemon does not create PID file

查看:42
本文介绍了作为守护程序运行celery不会创建PID文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从过去几天以来,我一直在为此努力工作,我已经看到了关于stackoverflow的其他问题(因为这是一个重复的问题),并且我已尽一切努力使这项工作正常进行,工人运转良好,但芹菜尚未启动.

I have been scratching my brains on this one since past few days, I have seen other issues on stackoverflow (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.

我运行命令:

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

令人沮丧的是:没有找到pidfiles 错误是我需要解决的问题.

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

我知道这个问题是一个重复的问题,但由于我已经尝试了所有问题,但仍然无法解决它,因此我仍然同意.

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.

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

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

init.d 脚本直接取自此处,然后我给了它所需的权限.

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

这是我的配置文件:

# 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

我已经使用此过程通过这篇文章来创建celery用户.

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

我的项目是Django项目,并且我已按照答案.

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 stackoverflow answer.

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

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

CELERYD_USER = ""
CELERYD_GROUP = ""

,同时在 init.d 脚本中将 DEFAULT_USER 的值更改为".问题仍然存在.

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

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

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:我已指定,并且针对隐私权问题他们有自己的名字.

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

推荐答案

我在ubuntu服务器上遇到了类似的问题[错误2]未找到文件.事实证明,即使您在celery示例文档中完成的celery.service配置中进行了设置,也不会自动创建/var/run/celery/目录.您可以创建该目录并手动授予权限,但是重新启动服务器后,该目录将消失,因为该目录位于临时目录中.在了解了Linux系统的运行方式之后,我发现您只需要在/etc/tmpfiles.d/celery.conf中用以下几行创建配置文件

I was having this a similar issue on my ubuntu server [ERROR 2]FILE NOT FOUND. Turns out, /var/run/celery/ Directories don't get automatically created even if you set that in the celery.service configuration done in the celery example docs. You can make that directory, and grant the right permissions manually, but as soon you reboot the server the directory will vanish because it's in a temporary directory. After some reading about how the linux system operates, I found out you just need to create a configuration file in /etc/tmpfiles.d/celery.conf with these lines

d /var/run/celery 0755 admin admin -
d /var/log/celery 0755 admin admin -                                       

注意:您将需要使用'admin'以外的其他user:group,也可以专门创建一个名为admin的user:group来处理您的芹菜过程.

Note: you will need to use a different user:group other than 'admin' or you can create a user:group called admin specifically to handle your celery process.

您可以通过输入

man tmpfiles.d

这篇关于作为守护程序运行celery不会创建PID文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆