Last active
September 14, 2020 14:57
-
-
Save diemuzi/62615c53292fbb1b681b13d60a346fe2 to your computer and use it in GitHub Desktop.
Celery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Path /etc/conf.d/celery | |
# App instance to use | |
CELERY_APP="application" | |
# Absolute or relative path to the 'celery' command: | |
CELERY_BIN="/home/gwhcp/api.gwhcp.dev/venv/bin/celery" | |
# Queue IP Addres | |
CELERY_QUEUE_IP="10.2.1.1" | |
# Where to chdir at start. | |
CELERYD_CHDIR="/home/gwhcp/api.gwhcp.dev/gwhcp_api/" | |
# Name of nodes to start | |
CELERYD_NODES="worker" | |
# How to call manage.py | |
CELERYD_MULTI="multi" | |
# Extra command-line arguments to the worker | |
CELERYD_OPTS="--time-limit=300 --concurrency=2" | |
# - %n will be replaced with the first part of the nodename. | |
# - %I will be replaced with the current child process index | |
# and is important when using the prefork pool to avoid race conditions. | |
CELERYD_PID_FILE="/var/run/celery/%n.pid" | |
CELERYD_LOG_FILE="/var/log/celery/%n.log" | |
#CELERYD_LOG_LEVEL="INFO" | |
CELERYD_LOG_LEVEL="DEBUG" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Celery Service | |
After=network.target | |
[Service] | |
Type=forking | |
User=gwhcp | |
Group=gwhcp | |
EnvironmentFile=-/etc/conf.d/celery | |
WorkingDirectory=/home/gwhcp/api.gwhcp.dev/public/gwhcp_api | |
ExecStart=/usr/bin/sudo /usr/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} -Q ${CELERY_QUEUE_IP} -A ${CELERY_APP} \ | |
--pidfile=${CELERYD_PID_FILE} \ | |
--logfile=${CELERYD_LOG_FILE} \ | |
--loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}' | |
ExecStop=/usr/bin/sudo /usr/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES} \ | |
--pidfile=${CELERYD_PID_FILE}' | |
ExecReload=/usr/bin/sudo /usr/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} -Q ${CELERY_QUEUE_IP} -A ${CELERY_APP} \ | |
--pidfile=${CELERYD_PID_FILE} \ | |
--logfile=${CELERYD_LOG_FILE} \ | |
--loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}' | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Path /etc/conf.d/worker | |
# Absolute or relative path to the 'manage.py' command: | |
MANAGE_BIN="/home/gwhcp/api.gwhcp.dev/public/gwhcp_api/manage.py" | |
# Absolute or relative path to the 'python3' command: | |
PYTHON_BIN="/home/gwhcp/api.gwhcp.dev/venv/bin/python" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Worker Daemon | |
After=network.target postgresql.service | |
[Service] | |
User=gwhcp | |
Group=gwhcp | |
EnvironmentFile=-/etc/conf.d/worker | |
ExecStart=/usr/bin/sh -c '${PYTHON_BIN} ${MANAGE_BIN} daemon_worker start' | |
ExecStop=/usr/bin/sh -c '${PYTHON_BIN} ${MANAGE_BIN} daemon_worker stop' | |
ExecReload=/usr/bin/kill -HUP $MAINPID | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment