celery守护程序-拒绝日志文件权限 [英] celery daemon - permission denied on log file

查看:128
本文介绍了celery守护程序-拒绝日志文件权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在将celery任务设置为守护程序,以便按计划处理数据。

I have been working on setting up my celery task as a daemon in order to process data on a schedule.

我一直在关注文档以便设置我的守护程序,但已遇到日志文件权限错误,

I have been following the docs in order to set up my daemon, but have been running into a log file permission error that has me stumped.

下面是我在Digital Ocean上的ubuntu盒上设置的配置

Below is the configuration i have set up on an ubuntu box on Digital Ocean

/ etc / default / celeryd

/etc/default/celeryd

# here we have a single node
CELERYD_NODES="w1"

CELERY_BIN = "/mix_daemon/venv/bin/celery"
CELERYD_CHDIR="/mix_daemon/"

CELERYD_OPTS="-A tasks worker --loglevel=info --beat"

# %n will be replaced with the nodename.
CELERYD_LOG_FILE="/var/log/celery/%n.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"
CELERY_CREATE_RUNDIR=0
CELERY_CREATE_LOGDIR=0

# Workers should run as an unprivileged user.
CELERYD_USER="celery"
CELERYD_GROUP="celery"

但是,何时我运行

sh -x /etc/init.d/celeryd start

我收到以下错误消息:

celery multi v3.1.7 (Cipater)
> Starting nodes...
> celery@mix: OK
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/john/mix_daemon/venv/lib/python2.7/site-packages/celery/bin/celeryd_detach.py", line 168, in <module> main()
File "/home/john/mix_daemon/venv/lib/python2.7/site-packages/celery/bin/celeryd_detach.py", line 165, in main
detached_celeryd(app).execute_from_commandline()
File "/home/john/mix_daemon/venv/lib/python2.7/site-packages/celery/bin/celeryd_detach.py", line 160, in execute_from_commandline
**vars(options)
File "/home/john/mix_daemon/venv/lib/python2.7/site-packages/celery/bin/celeryd_detach.py", line 42, in detach
with detached(logfile, pidfile, uid, gid, umask, working_directory, fake):
File "/home/john/mix_daemon/venv/local/lib/python2.7/site-packages/celery/platforms.py", line 314, in open
self.after_chdir()
File "/home/john/mix_daemon/venv/local/lib/python2.7/site-packages/celery/platforms.py", line 384, in after_chdir_do
logfile and open(logfile, 'a').close()
IOError: [Errno 13] Permission denied: '/var/log/celery/celery.log'
+ sleep 5
+ exit 0

我查看了此错误消息,在redmine项目中看到了此答案。因此,我尝试了以下操作,以允许芹菜工作者写入日志文件:

I looked this error message up and saw this answer from a redmine project. So i tried the following to try to allow for the celery worker to write to the log file:

$ sudo mkdir -p -m 2755 /var/log/celery
$ sudo chown celery:celery /var/log/celery

但是当我尝试启动守护程序时,仍然存在相同的错误。

but the same error remains when i try to start the daemon.

我是芹菜菜角,在这方面的任何帮助将不胜感激!

I am a celery noob, and any help on this would be greatly appreciated!

推荐答案

根据文档:


init脚本只能由root用户使用,并且shell配置文件也必须由root用户拥有。

The init scripts can only be used by root, and the shell configuration file must also be owned by root"

因此,您需要运行:

sudo chown root:root /etc/default/celeryd

sudo /etc/init.d/celeryd start

顺便说一下,celeryd配置文件中的语法无效:

By the way, you have invalid syntax in your celeryd config file:

CELERY_BIN = "/mix_daemon/venv/bin/celery"

不允许使用 =运算符使用空格,

spaces is not allowed with "=" operator, the correct is:

CELERY_BIN="/mix_daemon/venv/bin/celery"

还要检查一下,您的垃圾箱位于/ mix_daemon不是/ home // mix_daemon

Also check, that you have your bin in /mix_daemon not /home//mix_daemon

这篇关于celery守护程序-拒绝日志文件权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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