[Fixed]-Running celery as daemon does not create PID file

8πŸ‘

I was having this a similar issue on my ubuntu server [ERROR 2]FILE NOT FOUND. Turns out, /var/run/celery/ Directories don’t get automatically created even if you set that in the celery.service configuration done in the celery example docs. You can make that directory, and grant the right permissions manually, but as soon you reboot the server the directory will vanish because it’s in a temporary directory.
After some reading about how the linux system operates, I found out you just need to create a configuration file in /etc/tmpfiles.d/celery.conf with these lines

d /var/run/celery 0755 admin admin -
d /var/log/celery 0755 admin admin -                                       

Note: you will need to use a different user:group other than β€˜admin’ or you can create a user:group called admin specifically to handle your celery process.

You can read more about this configuration and the way it operates by typing

man tmpfiles.d

3πŸ‘

I had the issue and solved it just now, thank god! For me it was a permission issue. I had expected it to be in /var/run/celery or /var/log/celery but it turns out it was the log file I have setup Django logging for. For some reason celery wanted to write to that file (I have to look into that) but had no permission. I found the error with the verbose command and skip daemonization step:

# C_FAKEFORK=1 sh -x /etc/init.d/celeryd start 

This is an old thread but if anyone of you run into this error, I hope this may help!

Good luck!

πŸ‘€LanfeaR

1πŸ‘

I saw the same issue and it turned out to be a permissions issue.
Make sure to set the user/group that celery is running under to own the /var/log/celery/ and /var/run/celery/ folders.
See here for a step by step example:
Daemonizing celery

πŸ‘€spilafis

Leave a comment