14

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?

Gr1N
  • 1,337
  • 3
  • 14
  • 19

4 Answers4

16

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
    
sanchitarora
  • 882
  • 9
  • 18
1

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.

Artem Mezhenin
  • 5,539
  • 6
  • 32
  • 51
  • It is not recommended to start beat inside the celery worker for production http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html – RunLoop Feb 27 '16 at 06:52
  • this comment refers to some 2nd version of Celery. At that time it was a standard way of doing this. Not sure how thing are going now. – Artem Mezhenin Feb 29 '16 at 17:38
0

I solve my problem by setting user=root, but I think this is bad way...

Gr1N
  • 1,337
  • 3
  • 14
  • 19
  • 4
    Don't do that! Use root as sparingly as possible. Better follow @sanchitarora's answer and write the pid file in a directory you have write access to. `--pidfile=/tmp/celerybeat-myapp.pid` – j7nn7k Nov 01 '14 at 09:20
0

I ran into a similar issue. It was fixed by changing 2 setting:

  1. as mentioned above: adding --pidfile=/tmp/celerybeat-myapp.pid
  2. user = "an actual non-root user"

The default provided in some documentation "user = nobody" seem to cause extra permission errors with celerybeat.conf (not in celery.conf though).

Grae
  • 1
  • 1