Search code examples
ubuntuceleryceleryd

celery daemon: not found/celeryd error in configuration file


I was demonizing celery on Ubuntu by following the user guide and this question on SO. Briefly,

Download the init-script celeryd from celery github repo.

Save the configuration file from the user guide as celeryd.conf (to be distinguished form the init-script celeryd above) and edit the settings.

I have an extra step of transferring the above two files from a Windows machine to Ubuntu.

Then

sudo cp celeryd /etc/init.d/celeryd
sudo chmod +x /etc/init.d/celeryd
sudo cp celeryd.conf /etc/default/celeryd
sudo useradd -N -M --system -s /bin/bash celery
sudo addgroup celery
sudo adduser celery celery
sudo mkdir -p /var/run/celery
sudo mkdir -p /var/log/celery
sudo chown -R celery:celery /var/run/celery
sudo chown -R celery:celery /var/log/celery

However, when running

sudo /etc/init.d/celeryd start 

It throws the error:

not found/celeryd: 9: /etc/default/celeryd: 

The number 9 is the first non-comment line in the configuration file /etc/default/celeryd.

What is going on? How should I fix it? Thanks.


Solution

  • The reason is that the celeryd configuration file was edited on Windows and transferred to Ubuntu, therefore, it has '\r\n' as the line ending.

    The error message

    not found/celeryd: 9: /etc/default/celeryd: 
    

    was not informative. But searching it landed me on a post that pointed me to the right direction. Removing '\r' from the configuration file /etc/default/celeryd fixes the problem.

    So:

    cp /etc/default/celeryd celeryd
    cat celeryd | tr -d '\r' > celeryd
    sudo cp celeryd /etc/default/celeryd