Running celery as daemon does not create PID file (no permission issue)

可紊 提交于 2021-02-11 16:34:44

问题


I am trying to run celery (worker) as a daemon / service in Ubuntu server. I've follow their documentation (https://docs.celeryproject.org/en/stable/userguide/daemonizing.html)

However, when I start the daemon it says:

celery multi v5.0.4 (singularity)
> Starting nodes...
        > worker1@ubuntuserver: OK

But when I check the status it says:

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

I've seen some info on the internet about permissions. But not sure which one, because as far as I can see the permissions are right. It creates a log file in /var/log/celery, but it is empty.

When I ran the /etc/init.d/celeryd service for the first time, it created folders and permissions it self:

- Creating default directory: '/var/log/celery'
- Changing permissions of '/var/log/celery' to 02755
- Changing owner of '/var/log/celery' to 'root'
- Changing group of '/var/log/celery' to 'root'
- Creating default directory: '/var/run/celery'
- Changing permissions of '/var/run/celery' to 02755
- Changing owner of '/var/run/celery' to 'root'
- Changing group of '/var/run/celery' to 'root'

I've tried to give full permissions for everyone to the folders, but that didn't work (I know it is not safe, testing purpose only).

I am using this init.d/celeryd file (nothing changed in here): https://github.com/celery/celery/blob/master/extra/generic-init.d/celeryd

This is how my /etc/default/celeryd file looks like:

# 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
#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="/virtualenvs/def/bin/celery"

# App instance to use
# comment out this line if you don't use an app
CELERY_APP="VulnScanner"
# or fully qualified:
#CELERY_APP="proj.tasks:app"

# Where to chdir at start.
CELERYD_CHDIR="/home/marvin/VulnScanner/"

# Extra command-line arguments to the worker
CELERYD_OPTS="--time-limit=300 --concurrency=8"
# Configure node-specific settings by appending node name to arguments:
#CELERYD_OPTS="--time-limit=300 -c 8 -c:worker2 4 -c:worker3 2 -Ofair:worker1"

# Set logging level to DEBUG
CELERYD_LOG_LEVEL="DEBUG"

# %n will be replaced with the first part of 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.
#   You need to create this user manually (or you can choose
#   a user/group combination that already exists (e.g., nobody).
CELERYD_USER="root"
CELERYD_GROUP="root"

# If enabled pid and log directories will be created if missing,
# and owned by the userid/group configured.
CELERY_CREATE_DIRS=1

Summary of my goal: I have now 2 commands for celery, that I need to run manually. But the whole goal is to automate everything, so those 2 commands need to run always when the OS is turned on. Commands (both in Django project folder: VulnScanner):

celery -A VulnScanner worker -l INFO
celery -A VulnScanner beat -l DEBUG --scheduler django_celery_beat.schedulers:DatabaseScheduler

So in fact: I want to make a service of them.

I hope someone can help. I am lost.

来源:https://stackoverflow.com/questions/65338414/running-celery-as-daemon-does-not-create-pid-file-no-permission-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!