Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supervising celerybeat with supervisor and virtualenv

My celerybeat.conf

[program:celerybeat]
command=/path/app/env/bin/celery beat -A project.tasks --loglevel=INFO
environment=PYTHONPATH=/path/app/env/bin

user=nobody
numprocs=1
stdout_logfile=/var/log/celeryd.log
stderr_logfile=/var/log/celeryd.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
killasgroup=true
priority=998

When I starting supervisor I receive an error:

pidfile_fd = os.open(self.path, PIDFILE_FLAGS, PIDFILE_MODE)
celery.platforms.LockFailed: [Errno 13] Permission denied: '/celerybeat.pid'

Any idea how to solve this?

like image 770
Gr1N Avatar asked Sep 02 '13 20:09

Gr1N


2 Answers

The problem is that you have not specified any directory in the config file and the default directory then is '/' (root) which your user does not have permissions to write.

Setting the user as root solved your problem because now you had permission to write to '/' however it might not be the best solution. There are multiple ways you can solve this by including:

  1. Add a directory variable in the config and provide a path that your user has permissions to write to.

    directory=<path>
    
  2. Provide a pidfile argument to the celery command that you are using to start celery. Make sure you have write permissions to the path you specify for the pidfile.

    command=/path/app/env/bin/celery beat -A project.tasks --loglevel=INFO --pidfile=/tmp/celerybeat-myapp.pid
    
like image 155
sanchitarora Avatar answered Nov 15 '22 21:11

sanchitarora


Here is my (working) version for Celere beat:

[program:celery_periodic]
command=<venv_path>/bin/python <path>/manage.py celery worker --loglevel=info -c 1 -E -B -Q celery_periodic -f <log_folder>/celery_periodic.log -n periodic_worker
directory=<path>
user=<some_user>
group=<some_user>
autostart=true
autorestart=true
redirect_stderr=True
daemon = False
debug = False
stdout_logfile = NONE
stderr_logfile = NONE
loglevel = "info"

May be this helps.

Also check permissions on folder where you create pid file.

like image 39
Artem Mezhenin Avatar answered Nov 15 '22 19:11

Artem Mezhenin