概述
我一直在关注the docs以便设置我的守护进程,但是一直遇到一个日志文件权限错误让我难过.
以下是我在Digital Ocean上的ubuntu盒子上设置的配置
在/ etc /默认/ 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项目中看到了this answer.所以我尝试了以下尝试允许芹菜工作者写入日志文件:
$sudo mkdir -p -m 2755 /var/log/celery $sudo chown celery:celery /var/log/celery
但是当我尝试启动守护进程时仍然存在相同的错误.
我是一个芹菜菜鸟,对此的任何帮助将不胜感激!
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配置文件中的语法无效:
CELERY_BIN = "/mix_daemon/venv/bin/celery"
“=”运算符不允许使用空格,正确的是:
CELERY_BIN="/mix_daemon/venv/bin/celery"
还要检查/ bin / mix_daemon中的bin是不是/ home // mix_daemon
总结
以上是编程之家为你收集整理的python – celery守护程序 – 日志文件中的权限被拒绝全部内容,希望文章能够帮你解决python – celery守护程序 – 日志文件中的权限被拒绝所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧