Supervising celerybeat with supervisor and virtualenv

Gr1N picture Gr1N · Sep 2, 2013 · Viewed 8.3k times · Source

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?

Answer

sanchitarora picture sanchitarora · Nov 26, 2013

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