-
Notifications
You must be signed in to change notification settings - Fork 2
/
celery.service.template
46 lines (44 loc) · 1.64 KB
/
celery.service.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
[Unit]
Description=Celery Service
After=network.target
[Service]
Type=forking
# Apache HTTP Server user and group
User=wwwrun
Group=www
# environment variables:
# load Django settings for celery
Environment="DJANGO_SETTINGS_MODULE=datenwerft.settings"
# path to celery binary
Environment="CELERY_BIN=/srv/www/htdocs/datenwerft/virtualenv/bin/celery"
# celery app name, as defined in the Django project
Environment="CELERY_APP=datenwerft"
# celery worker node name
Environment="CELERYD_NODES=w1"
# optional parameters
Environment="CELERYD_OPTS=--time-limit=300 --concurrency=8"
# celery log and run directories (user must own these directories)
Environment="CELERYD_PID_FILE=/var/run/celery/%n.pid"
Environment="CELERYD_LOG_FILE=/var/log/celery/%n%I.log"
# celery log level
Environment="CELERYD_LOG_LEVEL=INFO"
# celery working directory (same directory in which manage.py is located)
WorkingDirectory=/srv/www/htdocs/datenwerft/datenwerft
# start/stop/reload commands for celery worker
ExecStart=/bin/sh -c '${CELERY_BIN} -A $CELERY_APP multi start $CELERYD_NODES \
--pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} \
--loglevel="${CELERYD_LOG_LEVEL}" $CELERYD_OPTS'
ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait $CELERYD_NODES \
--pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} \
--loglevel="${CELERYD_LOG_LEVEL}"'
ExecReload=/bin/sh -c '${CELERY_BIN} -A $CELERY_APP multi restart $CELERYD_NODES \
--pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} \
--loglevel="${CELERYD_LOG_LEVEL}" $CELERYD_OPTS'
# restart service after 5 seconds if the service crashes
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target