[英]celery daemon - permission denied on log file
I have been working on setting up my celery task as a daemon in order to process data on a schedule. 我一直在将celery任务设置为守护程序,以便按计划处理数据。
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. 我一直在关注文档以设置我的守护程序,但是一直遇到一个日志文件权限错误,这让我感到困惑。
Below is the configuration i have set up on an ubuntu box on Digital Ocean 以下是我在Digital Ocean的ubuntu盒上设置的配置
/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"
however, when i run 但是,当我跑步时
sh -x /etc/init.d/celeryd start
i get the following error message: 我收到以下错误消息:
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
I looked this error message up and saw this answer from a redmine project. 我查找了此错误消息,并从redmine项目中看到了这个答案 。 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! 我是一个芹菜菜鸟,对此的任何帮助将不胜感激!
It helps me: 它帮助到我:
sudo chown -R myuser:root /var/run/celery/
sudo chown -R myuser:root /var/log/celery/
According to the documentation: 根据文档:
The init scripts can only be used by root, and the shell configuration file must also be owned by root" 初始化脚本只能由root使用,并且shell配置文件也必须归root所有”
So, you need to run: 因此,您需要运行:
sudo chown root:root /etc/default/celeryd
and 和
sudo /etc/init.d/celeryd start
By the way, you have invalid syntax in your celeryd config file: 顺便说一下,您的celeryd配置文件中的语法无效:
CELERY_BIN = "/mix_daemon/venv/bin/celery"
spaces is not allowed with "=" operator, the correct is: “ =”运算符不允许使用空格,正确的是:
CELERY_BIN="/mix_daemon/venv/bin/celery"
Also check, that you have your bin in /mix_daemon not /home//mix_daemon 还要检查一下,是否在/ mix_daemon中有bin,而不是/ home // mix_daemon
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.