Created
March 28, 2021 19:00
-
-
Save jclosure/e98792962471095f42f959275440d9a6 to your computer and use it in GitHub Desktop.
Supervisord config for running multiple processes in a single container.
This file contains 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
## service.conf | |
# skel ref: https://github.com/Supervisor/supervisor/blob/master/supervisor/skel/sample.conf | |
# requires: | |
# pip install supervisor | |
# pip install supervisord-dependent-startup | |
[supervisord] | |
pidfile=/tmp/supervisord.pid | |
nodaemon=true | |
# user=nobody | |
user=root | |
loglevel=INFO | |
[rpcinterface:supervisor] | |
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | |
[unix_http_server] | |
file=/tmp/supervisor.sock | |
[supervisorctl] | |
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket | |
prompt=worker_supervision ; cmd line prompt (default "supervisor") | |
history_file=~/.sc_history ; use readline history if available | |
[program:webservice] | |
command=bash startup/start_webservice.sh | |
numprocs=1 | |
priority=1 | |
autostart=false | |
autorestart=true | |
startretries=5 | |
startsecs=5 | |
stderr_logfile=/dev/stdout | |
stderr_logfile_maxbytes = 0 | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes = 0 | |
environment = PYTHONUNBUFFERED=1 | |
dependent_startup=true | |
[program:nats_worker] | |
command=python startup/start_nats_worker.py | |
numprocs=3 | |
priority=5 | |
process_name = %(program_name)s_%(process_num)02d | |
autostart=false | |
autorestart=true | |
startretries=5 | |
startsecs=10 | |
stderr_logfile=/dev/stderr | |
stderr_logfile_maxbytes = 0 | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes = 0 | |
environment = PYTHONUNBUFFERED=1 | |
dependent_startup=true | |
dependent_startup_wait_for=webservice:running | |
# ensures ordered startup | |
[eventlistener:dependentstartup] | |
command=python -m supervisord_dependent_startup -c supervisord.conf | |
autostart=true | |
autorestart=unexpected | |
startretries=0 | |
exitcodes=0,3 | |
events=PROCESS_STATE_RUNNING | |
# cleanly exits the docker container by stopping supervisord if the number of retries has been exceeded | |
[eventlistener:quit_on_failure] | |
events=PROCESS_STATE_FATAL | |
command=sh -c 'echo "READY"; while read -r line; do echo "$line"; kill -SIGTERM $PPID; done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment