我试图将celery守护程序设置为在启动时在Alpine docker容器中运行。
这是Dockerfile部分:
# adding OpenRC for enabling/starting services
RUN apk add openrc --no-cache
RUN mkdir -p /etc/default
# Celery daemon setup
COPY docker/celeryd /etc/init.d/
COPY docker/celeryd.conf /etc/default/celeryd
RUN chmod +x /etc/init.d/celeryd
RUN addgroup celery
RUN adduser celery -G celery -s /bin/sh -D
RUN mkdir -p /var/log/celery/ && chown celery:celery /var/log/celery/
RUN mkdir -p /var/run/celery/ && chown celery:celery /var/run/celery/
RUN rc-update add /etc/init.d/celeryd default
celeryd脚本是这样的:
https://github.com/celery/celery/blob/master/extra/generic-init.d/celeryd
和芹菜配置文件(docker/celeryd.conf
)的内容是:
# Names of nodes to start
# most people will only start one node:
CELERYD_NODES="worker"
# Absolute or relative path to the 'celery' command:
CELERY_BIN="celery"
# App instance to use
CELERY_APP="config.celery:app"
# Where to chdir at start.
CELERYD_CHDIR="/var/www/my_proj/"
# 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="INFO"
# %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="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
构建成功运行,但是在运行容器并检查celeryd状态时,我得到了这个:
/var/www/my_proj # /etc/init.d/celeryd status
celery init v10.1.
Using config script: /etc/default/celeryd
celeryd down: no pidfiles found
虽然手动启动时没有问题:
/var/www/my_proj # /etc/init.d/celeryd start
celery init v10.1.
Using config script: /etc/default/celeryd
celery multi v4.1.0 (latentcall)
> Starting nodes...
> worker@0600bf7dec4a: OK
关于它可能是什么的任何提示?
由于