gpt4 book ai didi

python - celery 即服务 - PermissionError : [Errno 13] Permission denied: '/var/run/celery'

转载 作者:行者123 更新时间:2023-12-05 06:04:54 27 4
gpt4 key购买 nike

我正在尝试创建一个运行 celery 的服务,但我遇到了权限问题。我在许多教程中看到 pidfile 路径是 /var/run/celery/%n.pid 但似乎我的用户没有权限写入 run

当我启动服务时,这是它返回的内容:

PermissionError: [Errno 13] Permission denied: '/var/run/celery' 

celery.service

[Unit]
Description=Celery Service
After=network.target

[Service]
Type=forking
User=master
Group=master
EnvironmentFile=/etc/conf.d/celery
WorkingDirectory=/home/master/myproject/
ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES} \
--pidfile=${CELERYD_PID_FILE}'
ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'

[Install]
WantedBy=multi-user.target

celery.conf

CELERYD_NODES="celery-worker"

CELERY_BIN="/home/master/.virtualenvs/myproject/bin/celery"

# App instance to use
CELERY_APP="myproject"


CELERYD_MULTI="multi"
# Extra command-line arguments to the worker
CELERYD_OPTS="--time-limit=300 --concurrency=3"

# %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"
CELERYD_LOG_LEVEL="INFO"

如何让它发挥作用?

最佳答案

不知道这是否是最好的方法,但这是我解决问题的方法...

$sudo mkdir /var/run/celery

用户和组不一定是 celery ..

$sudo chown -R celery:celery /var/run/celery
$sudo chmod o+w /var/run/celery

然后

$sudo service celery restart

关于python - celery 即服务 - PermissionError : [Errno 13] Permission denied: '/var/run/celery' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66172503/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com