Skip to content

Instantly share code, notes, and snippets.

@santoshpy
Last active June 26, 2020 15:26
Show Gist options
  • Save santoshpy/1fa7195fb2c21603efa6972e2176a318 to your computer and use it in GitHub Desktop.
Save santoshpy/1fa7195fb2c21603efa6972e2176a318 to your computer and use it in GitHub Desktop.
Celery worker and scheduler in the background as a daemon with Supervisor.
; install supervisor > sudo apt-get install supervisor
; adding configuration files to the “/etc/supervisor/conf.d/” directory on the remote server
; ==========================
; celery worker supervisor
; ==========================
; the name of your supervisord program
[program:{{appname}}_celery]
; The directory to your Django project
directory=/home/{user}/vent/src
; If supervisord is run as the root user, switch users to this UNIX user account before doing any processing.
user={user}
; Supervisor will start as many instances of this program as named by numprocs
numprocs=1
; Put process stdout output in this file
stdout_logfile=/home/{user}/venv/logs/celery/{appname}_worker.log
; Put process stderr output in this file
stderr_logfile=/home/{user}/venv/logs/celery/{appname}_worker.log
; If true, this program will start automatically when supervisord is started
autostart=true
; Set full path to celery program if using virtualenv
command=/home/{user}/venv/bin/celery -A picha --loglevel=INFO
; May be one of false, unexpected, or true. If false, the process will never
; be autorestarted. If unexpected, the process will be restart when the program
; exits with an exit code that is not one of the exit codes associated with this
; process’ configuration (see exitcodes). If true, the process will be
; unconditionally restarted when it exits, without regard to its exit code.
autorestart=true
; The total number of seconds which the program needs to stay running after
; a startup to consider the start successful.
startsecs=10
; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600
; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true
; if your broker is supervised, set its priority higher
; so it starts first
priority=998
; Save this file and exit
; sudo supervisorctl reread
; sudo supervisorctl update
; sudo supervisorctl status pichacelery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment