General documentation / cheat sheets for various languages and services

Supervisor

‘Supervisor’ refers to the supervisord + supervisorctl + program config file ecosystem.

Package website (extensively documented): supervisord.org

Installing

Become root, first:

sudo su root

And then use pip (or easy_install) to install directly from PyPI and set up some basic configuration:

pip install --upgrade supervisor
mkdir /etc/supervisor.d/
echo_supervisord_conf > /etc/supervisord.conf

Or just use the following trimmed down config file:

[inet_http_server]
port=127.0.0.1:911

[supervisorctl]
serverurl=http://localhost:991

[supervisord]
logfile=/tmp/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/tmp/supervisord.pid
nodaemon=false               ; (start in foreground if true;default false)
minfds=1024
minprocs=200

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[include]
files = /etc/supervisor.d/*

/etc/supervisord.conf is a special location – it is the default that supervisor will be looking for. You can put it somewhere else and use -c whenever calling supervisord, but you’ll also have to use -c when calling supervisorctl, which is annoying.

Now edit /etc/supervisord.conf and put the following at the bottom:

[include]
files = /etc/supervisor.d/*

Put the following info a file /etc/init.d/supervisord, with 755 permissions:

#!/bin/sh
# chkconfig: - 64 36
# description: Supervisor Daemon

. /etc/rc.d/init.d/functions

name=supervisord
bin=/usr/bin/supervisord
pid=/tmp/supervisord.pid

start()
{
  echo -n Starting $name:
  daemon $bin -c /etc/supervisord.conf
  [ -f $pid ] && success || failure
  echo
}

stop()
{
  echo -n Stopping $name:
  [ -f $pid ] && killproc $name || success
  echo
}

case "$1" in
  start)
    start
  ;;
  stop)
    stop
  ;;
  status)
    status $name
  ;;
  restart)
    stop
    start
  ;;
  *)
    echo Usage: $0 '{start|stop|status|restart}'
    exit 2
esac

And to add that init.d script on a Ubuntu machine, also run:

sudo chkconfig --level 345 supervisord on

If you just want to kickstart supervisord for now:

sudo supervisord

Monitoring

sudo supervisorctl

Now you can add “program:” config files in /etc/supervisor.d/, call sudo supervisorctl update, and it’ll read in changes and add start up your applications as needed.

Examples

Program configuration documentation

Process monitors