Pull request to allow supervisor to send arbitrary signals to processes

https://github.com/Supervisor/supervisor/pull/477

Let’s you do stuff like:

$ supervisorctl
cat:0                            RUNNING   pid 57305, uptime 0:00:07
cat:1                            RUNNING   pid 57304, uptime 0:00:07
cat:2                            RUNNING   pid 57307, uptime 0:00:07
cat:3                            RUNNING   pid 57306, uptime 0:00:07
cat:4                            RUNNING   pid 57308, uptime 0:00:07
dog:0                            RUNNING   pid 57300, uptime 0:00:07
dog:1                            RUNNING   pid 57299, uptime 0:00:07
dog:2                            RUNNING   pid 57302, uptime 0:00:07
dog:3                            RUNNING   pid 57301, uptime 0:00:07
dog:4                            RUNNING   pid 57303, uptime 0:00:07
supervisor> help signal
signal <signal name> <name>	      Signal a process
signal <signal name> <gname>:*        Signal all processes in a group
signal <signal name> <name> <name>    Signal multiple processes or groups
supervisor> signal 1 dog:3 dog:4
dog:3: signalled
dog:4: signalled
supervisor> signal HUP dog:3 dog:4
dog:3: signalled
dog:4: signalled
supervisor> signal HUP dog:*
dog:1: signalled
dog:0: signalled
dog:3: signalled
dog:2: signalled
dog:4: signalled
supervisor> signal USR1 dog:1 dog:2
dog:1: signalled
dog:2: signalled

Also, if you can’t wait for supervisor to support this, the mr.laforge package supplies a supervisor plugin that can be used to send signals to processes:

$ supervisorctl kill HUP nginx

That said, it would be nice to have this built into supervisor…

Fun with zc.buildout

I’ve been exploring zc.buildout (another link) lately. In the past, I’ve typically gone the simpler route of using virtualenv and pip, but I knew that buildout could do some powerful things and I’ve long wanted to kick the tires.

I’m using buildout for a Django project at work and it’s working out pretty well, though I sense that I might just be scratching the surface. Tonight, I wanted to play with some of the other buildout recipes.

The result is this educational buildout gist that demonstrates a recipe for building and deploying Varnish and a recipe for installing Supervisor.

The supervisor manages two processes — a simple one-line Python “origin server” on port 8080 and a Varnish reverse proxy on port 8000.

I think I love supervisor

Supervisor is simple. It’s easy to use. It lets me start, stop, and monitor all my little processes:

$ supervisorctl status
celeryd                          STOPPED    Apr 15 03:17 PM
dropboxd                         RUNNING    pid 8442, uptime 1 day, 1:04:48
rabbitmq                         STOPPED    Apr 15 03:17 PM
redis                            STOPPED    Apr 15 04:08 PM

Manage rabbitmq-server with supervisor

First I installed rabbitmq:

$ brew install rabbitmq
...
==> make install
/usr/local/Cellar/rabbitmq/2.4.1: 114 files, 1.6M, built in 41 seconds

Running rabbitmq-server will start a server in the foreground, which is kind of inconvenient.

So I installed Supervisor:

$ pip install supervisor
Downloading/unpacking supervisor
  Downloading supervisor-3.0a10.tar.gz (438Kb): 438Kb downloaded
...
    Installing echo_supervisord_conf script to /Library/Frameworks/Python.framework/Versions/2.7/bin
    Installing pidproxy script to /Library/Frameworks/Python.framework/Versions/2.7/bin
    Installing supervisorctl script to /Library/Frameworks/Python.framework/Versions/2.7/bin
    Installing supervisord script to /Library/Frameworks/Python.framework/Versions/2.7/bin
Successfully installed meld3 supervisor
Cleaning up...

Then to set up Supervisor to manage rabbitmq:

$ echo_supervisord_conf > supervisord.conf
$ sudo mv supervisord.conf /etc
$ sudo vim /etc/supervisord.conf
...
$ grep rabbitmq /etc/supervisord.conf 
[program:rabbitmq]
command=/usr/local/sbin/rabbitmq-server

and then to start up rabbitmq and test that it’s working:

$ supervisord
$ supervisorctl status
rabbitmq                         RUNNING    pid 60340, uptime 0:00:04
$ rabbitmqctl status
Status of node 'rabbit@ladyproud-lm' ...
[{pid,60340},
 {running_applications,[{rabbit,"RabbitMQ","2.4.1"},
                        {os_mon,"CPO  CXC 138 46","2.2.5"},
                        {sasl,"SASL  CXC 138 11","2.1.9.3"},
                        {mnesia,"MNESIA  CXC 138 12","4.4.17"},
                        {stdlib,"ERTS  CXC 138 10","1.17.3"},
                        {kernel,"ERTS  CXC 138 10","2.14.3"}]},
 {nodes,[{disc,['rabbit@ladyproud-lm']}]},
 {running_nodes,['rabbit@ladyproud-lm']}]
...done.
$ rabbitmqctl list_exchanges
Listing exchanges ...
amq.direct      direct
amq.topic       topic
amq.rabbitmq.log        topic
amq.fanout      fanout
amq.headers     headers
        direct
amq.match       headers
...done.