Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Supervisor (https://pypi.python.org/pypi/supervisor) config for StarCluster's loadbalancer
[unix_http_server]
file=/tmp/supervisor.sock
[supervisord]
logfile=/tmp/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/tmp/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
[program:loadbalancer]
command=starcluster loadbalance mycluster -m 20 -n 1 -w 60 -a 20 -s 60 -i 60 -k 50
autorestart=true
@jtriley

This comment has been minimized.

Copy link
Owner Author

@jtriley jtriley commented Jan 8, 2014

To use this config you first need to install supervisor:

$ pip install supervisor

Then launch supervisord with the above config file:

$ supervisord -c /path/to/starcluster_loadbalance_supervisor.conf

This will launch the loadbalancer and continuously monitor it to make sure it's always up. The above supervisor config will relaunch the loadbalancer if it crashes for any reason.

Once the loadbalancer is running under supervisor you can monitor and control it using the supervisorctl command:

$ supervisorctl -c /path/to/starcluster_loadbalance_supervisor.conf
loadbalancer                        RUNNING    pid 1626, uptime 51 days, 0:01:42
supervisor>

This drops you into a supervisor prompt that supports a number of commands:

supervisor> help

default commands (type help <topic>):
=====================================
add    clear  fg        open  quit    remove  restart   start   stop  update 
avail  exit   maintail  pid   reload  reread  shutdown  status  tail  version

To monitor the loadbalancer status:

supervisor> status loadbalancer
loadbalancer                        RUNNING    pid 1626, uptime 51 days, 0:01:42

To monitor the loadbalancer output:

supervisor> tail -f loadbalancer

To restart the loadbalancer:

supervisor> restart loadbalancer

To stop the loadbalancer:

supervisor> stop loadbalancer

To see help info and usage for the other supervisorctl commands type help followed by the command:

supervisor> help tail
tail [-f] <name> [stdout|stderr] (default stdout)
Ex:
tail -f <name>          Continuous tail of named process stdout
                        Ctrl-C to exit.
tail -100 <name>        last 100 *bytes* of process stdout
tail <name> stderr      last 1600 *bytes* of process stderr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment