Skip to content

Instantly share code, notes, and snippets.

@skyrocknroll
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyrocknroll/9409854 to your computer and use it in GitHub Desktop.
Save skyrocknroll/9409854 to your computer and use it in GitHub Desktop.
long running process startup monitoring. supervisord monit forever & pm2 .

Supervisord tried

pip install supervisord ??

apt-get install supervisord ??

added config files

supervisorctl  ? : prints all the help.
supervisorctl list
supervisorctl reread
supervisorctl update
supervisorctl stop <appname>
supervisorctl start <appname>

supervisorctl restart all 


When running django server supervisorctl stop didnt kill all the process

When running a python multiprocessing based python script Adding stopasgroup=true killasgroup=true made it to stop all the parent and child process

Supervisor can start the process during the boot time.

Supervisor can only monitor whether the process is running or not.

But monit can check resource usage also and take action based on that. http://stackoverflow.com/questions/12156434/what-is-the-adavantage-of-using-supervisord-over-monit

When running django server super

PM2 better than forever ?

https://github.com/Unitech/pm2

http://devo.ps/blog/2013/06/26/goodbye-node-forever-hello-pm2.html

[unix_http_server]
file=/var/tmp/supervisor.sock ; path to your socket file
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisord]
http_port=/var/tmp/supervisor.sock ; (default is to run a UNIX domain socket server)
;http_port=127.0.0.1:9001 ; (alternately, ip_address:port specifies AF_INET)
;sockchmod=0700 ; AF_UNIX socketmode (AF_INET ignore, default 0700)
;sockchown=nobody.nogroup ; AF_UNIX socket uid.gid owner (AF_INET ignores)
;umask=022 ; (process file creation umask;default 022)
logfile=/var/log/supervisor/supervisord.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=debug ; (logging level;default info; others: debug,warn)
pidfile=/var/run/supervisord.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)
;nocleanup=true ; (don't clean up tempfiles at start;default false)
;http_username=user ; (default is no username (open system))
;http_password=123 ; (default is no password (open system))
;childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP)
;user=chrism ; (default is current user, required if root)
;directory=/tmp ; (default is not to cd during start)
;environment=KEY=value ; (key value pairs to add to environment)
[supervisorctl]
serverurl=unix:///var/tmp/supervisor.sock ; use a unix:// URL for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris ; should be same as http_username if set
;password=123 ; should be same as http_password if set
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
; The below sample program section shows all possible program subsection values,
; create one or more 'real' program: sections to be able to control them under
; supervisor.
;[program:theprogramname]
;command=/bin/cat ; the program (relative uses PATH, can take args)
;priority=999 ; the relative start priority (default 999)
;autostart=true ; start at supervisord start (default: true)
;autorestart=true ; retstart at unexpected quit (default: true)
;startsecs=10 ; number of secs prog must stay running (def. 10)
;startretries=3 ; max # of serial start failures (default 3)
;exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs=10 ; max num secs to wait before SIGKILL (default 10)
;user=chrism ; setuid to this UNIX account to run the program
;log_stdout=true ; if true, log program stdout (default true)
;log_stderr=true ; if true, log program stderr (def false)
;logfile=/var/log/cat.log ; child log path, use NONE for none; default AUTO
;logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;logfile_backups=10 ; # of logfile backups (default 10)
[program:batch]
command=/usr/bin/python /home/ec2-user/simplify_audit/MinjarSimplifyITAudit/app/batch/StartBatch.py ; the program (relative uses PATH, can take args)
priority=500 ; the relative start priority (default 999)
autostart=true ; start at supervisord start (default: true)
;autorestart=true ; retstart at unexpected quit (default: true)
logfile=/var/log/batch-audit.log ; child log path, use NONE for none; default AUTO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment