Controlling a TurboGears application with supervisor - Part II
A few days ago I described how I set up supervisor to control a TurboGears application on Ubuntu. I was using supervisor version 1.0.7, because I wasn't aware of the existence of supervisor2, which supersedes version 1.x and has a lot more features. Since then, I have successfully set up supervisor2 as well and I am now using it exclusively to start/stop and monitor TurboGears apps on my production machine.
Installing and setting up supervisor2 was a lot easier than getting version 1.x to run. Therefore I will not go into such detail as I did in my last article, but instead, I will just give you a listing of shell commands that should get supervisor2 up and running in almost no time:
cd /tmp wget --output-document=supervisor-2.1b1.tar.gz \ http://www.plope.com/software/supervisor2/supervisor-2.1b1.tar.gz/download tar xzf supervisor-2.1b1.tar.gz cd supervisor-2.1b1 python setup.py build sudo python setup.py install --prefix=/usr/local wget http://chrisarndt.de/projects/cblog/supervisor2.init sudo install supervisor2.init /etc/init.d/supervisor sudo update-rc.d supervisor defaults wget http://chrisarndt.de/projects/cblog/supervisor.default sudo install -m 644 supervisor.default /etc/default/supervisor wget http://chrisarndt.de/projects/cblog/supervisord2.conf # adapt configuration to your needs # at the least, set socket, user and password! # and add services as needed vi supervisord2.conf sudo install -m 644 supervisord2.conf /etc/supervisord.conf sudo invoke-rc.d supervisor start # control if everything is working supervisorctl status cd /tmp rm -rf supervisor-2.1b1
The only manual intervention necessary is to adapt the supervisord.conf configuration file to your system by setting a user name and password and by defining services as needed. supervisor2 now uses an INI-style configuration file format, which should be fairly self-explanatory.
I have have updated the SysV init script I wrote for supervisor 1.x for supervisor2 - I only had to change a few paths for the configuration and log files - and provided it as a download, so you don't have to go to the same trouble. The commands above will download all contributed files from my server when needed, if you want to download them manually, you can find them - packed into a tarball - here.
So, re-evaluating my assessment of supervisor 1.x for supervisor2, I have to remove my complaints about the bumpy installation process and the 'hidden' documentation (the README file now contains everything you need to know) and also add a few new Pros:
- Handy web HTTP/Webinterface to control services
- Remote control of services through XMPL-RPC (think xmlrpclib.py!)