Skip to content

Instantly share code, notes, and snippets.

@anhtran
Last active July 26, 2019 09:03
Show Gist options
  • Save anhtran/205d187c7e1df81c8c8f834c4cc68c9c to your computer and use it in GitHub Desktop.
Save anhtran/205d187c7e1df81c8c8f834c4cc68c9c to your computer and use it in GitHub Desktop.
Sample of settings for running django service inside python-supervisor (standalone)
#!/bin/sh
supervisorctl -c /path/to/service/supervisord.ini $@
#!/bin/sh
supervisord -c /path/to/service/supervisord.ini
;; change yourservicename, /path/to/service/, djangoprojectname to match your context
[unix_http_server]
file=/tmp/supervisord_yourservicename.sock ; (the path to the socket file)
[supervisord]
logfile=supervisord_yourservicename.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord_yourservicename.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
;umask=022 ; (process file creation umask;default 022)
;;user=chrism ; (default is current user, required if root)
;;identifier=supervisor ; (supervisord identifier, default is 'supervisor')
;;directory=/tmp ; (default is not to cd during start)
;;nocleanup=true ; (don't clean up tempfiles at start;default false)
;;childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP)
;;environment=KEY="value" ; (key value pairs to add to environment)
;;strip_ansi=false ; (strip ansi escape codes in logs; def. false)
;; the below section must remain in the config file for RPC
;; (supervisorctl/web interface) to work, additional interfaces may be
;; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisord_yourservicename.sock ; use a unix:// URL for a unix socket
[program:django]
command=/path/to/service/venv/bin/gunicorn djangoprojectname.wsgi -b localhost:9999 -w 3
directory=/path/to/service
autostart=true
priority=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment