1. Init-script: celeryd
1.1. celeryd
What to do?
-
Create
/etc/init.d/celeryd
with the content from celery repo -
Make
celeryd
executable
How?
sudo nano /etc/init.d/celeryd
Copy-paste code from celery repo to the file
Save celeryd
(CTR+X, y, Enter
from nano)
Run following commands from the terminal:
sudo chmod 755 /etc/init.d/celeryd
sudo chown root:root /etc/init.d/celeryd
1.2. Configuration
What to do?
- Create
/etc/default/celeryd
- Configure it
How?
sudo nano /etc/default/celeryd
Configure it depending on what you need. Options and template can be found in the docs
My example:
Note
You can set your environment variables in /etc/default/celeryd
.
For more info about environment variable take a look at this SO answer
Test it
You can check if the worker is active by:
sudo /etc/init.d/celeryd start
sudo /etc/init.d/celeryd status
Don’t forget to stop the worker:
sudo /etc/init.d/celeryd stop
2. Init-script: celerybeat
2.1. celerybeat
What to do?
-
Create
/etc/init.d/celerybeat
with the content from celery repo -
Make
celerybeat
executable
How?
sudo nano /etc/init.d/celerybeat
Copy-paste code from celery repo to the file
Save celerybeat
(CTR+X, y, Enter
from nano)
Run following commands from the terminal:
sudo chmod 755 /etc/init.d/celerybeat
sudo chown root:root /etc/init.d/celerybeat
2.2. Configuration
What to do?
Configurate either /etc/default/celerybeat
or stick with /etc/default/celeryd
How?
sudo nano /etc/default/celerybeat
Configure it depending on what you need. Options and template can be fount in the docs
Note
If you don’t require any special configuration you can use /etc/default/celeryd
as you config file. Just don’t create /etc/default/celerybeat
Test it
You can check if the beat is active by:
sudo /etc/init.d/celerybeat start
sudo /etc/init.d/celerybeat status
Don’t forget to stop the worker:
sudo /etc/init.d/celerybeat stop
3. Maintenance
As it was show you can control worker and beat with the following commands:
/etc/init.d/celeryd {start|stop|restart}
/etc/init.d/celerybeat {start|stop|restart}
If you want to see the logs you can open CELERYD_LOG_FILE
provided in /etc/default/celeryd
. In our example is was /var/log/celery/worker1.log
:
sudo nano /var/log/celery/worker1.log