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.
Below is the configuration i have set up on an ubuntu box on Digital Ocean
/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. 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!