# vi /srv/celery/celery.conf
CELERYD_NODES="worker1"
CELERY_BIN="/home/ubuntu/.pyenv/versions/<pyenv_name>/bin/celery"
CELERY_APP="config"
CELERYD_MULTI="multi"
CELERYD_OPTS="--time-limit=300 --concurrency=2"
CELERYD_PID_FILE="/srv/celery/celery-%n.pid"
CELERYD_LOG_FILE="/srv/celery/celery-%n%I.log"
CELERYD_LOG_LEVEL="INFO"
# vi /etc/systemd/system/celery.service
[Unit]
Description=Celery Service
After=network.target
[Service]
Type=forking
EnvironmentFile=/srv/celery/celery.conf
WorkingDirectory=/home/ubuntu/<project_directory>
ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \
-A ${CELERY_APP} --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}'
ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
StandardError=syslog
[Install]
WantedBy=multi-user.target