Start celery daemon via systemd
8,622
After a whole bunch of experimenting i came up with this configuration for the service (modified to match your example):
[Unit]
Description=Celery Server
After=network.target
[Service]
Type=oneshot
KillMode=control-group
RemainAfterExit=yes
Restart=no
ExecStart=/usr/bin/python2 /home/myuser/path/to/Django/myproject/manage.py celeryd_multi start w1 --pidfile="/tmp/%n.pid" --logfile="/var/log/celery/%n.log" --loglevel=INFO --time-limit=300
ExecStop=/usr/bin/python2 /home/myuser/path/to/Django/myproject/manage.py celeryd_multi stopwait w1 --pidfile="/tmp/%n.pid"
[Install]
WantedBy=multi-user.target
Related videos on Youtube
Author by
Max
Updated on September 18, 2022Comments
-
Max over 1 year
In the /usr/lib/systemd/system/celery.service:
[Unit] Description=Celery Nodes Daemon After=network.target [Service] Type=forking PIDFile=/var/run/celery/main.pid ExecStart=/usr/bin/python2 /home/myuser/path/to/Django/myproject/manage.py celeryd_multi start w1 --pidfile="/var/run/celery/%n.pid" --logfile="/var/log/celery/%n.log" --cmd="-m celery.bin.celeryd_detach" ExecStop=/usr/bin/python2 /home/myuser/path/to/Django/myproject/manage.py celeryd_multi stopwait w1 --pidfile="/var/run/celery/%n.pid" [Install] WantedBy=multi-user.target
In the shell:
$ sudo systemctl enable celery.service ln -s '/usr/lib/systemd/system/celery.service' '/etc/systemd/system/multi-user.target.wants/celery.service' $ sudo systemctl start celery.service Job for celery.service failed. See 'systemctl status celery.service' and 'journalctl -xn' for details. $ sudo systemctl status celery.service celery.service - Celery Nodes Daemon Loaded: loaded (/usr/lib/systemd/system/celery.service; enabled) Active: failed (Result: exit-code) since Пт 2013-03-29 13:22:24 NOVT; 38s ago Process: 32273 ExecStart=/usr/bin/python2 /home/anarchist/Desktop/Develop/Django/myproject/manage.py celeryd_multi start w1 --pidfile="/var/run/celery/%n.pid" --logfile="/var/log/celery/%n.log" --cmd="-m celery.bin.celeryd_detach" (code=exited, status=1/FAILURE)
In journalctl -xn nothing about celery. How to start the celery daemon via systemd?
-
Alp about 11 yearsi am very interested in this question, too
-
FSMaxB over 10 yearsIf this question is still relevant, you might try to put the ExecStart and ExecStop commands in separate shell scripts in /usr/local/bin
-
Max over 10 yearsIn the Arch /usr/bin
-
-
Max about 11 yearsIts final version I sent to the developer. We are waiting for new versions. If interested github.com/celery/celery/pull/1295
-
Alp about 11 yearsthanks for the hint. by the way if you think my answer has helped please consider upvoting and/or accepting it
-
Pavel Šimerda about 9 yearsPlease note that
After=network.target
is only intended for shutdown, not startup. If you want to wait for network configuration, you should useWants=network-online.target
andAfter=network-online.target
.