One of my (super cool) clients needed also to start/stop daemons when configuration changes. The solution was to have a script that updates supervisord.conf every time we have a configuration change and then selectively start/stop on the daemons that have change (by default if your run supervisorctl update, it will restart all the daemons).
For this example, I''ll assume that the daemon processes are python -m SimpleHTTPServer and I have a list of port I''d like to listen on. This list of ports might change.
Example Usage
$ ./updated.py 8000 8001 8002
$ supervisorctl status
httpd-8000 RUNNING pid 31768, uptime 0:00:04
httpd-8001 RUNNING pid 31767, uptime 0:00:04
httpd-8002 RUNNING pid 31766, uptime 0:00:04
$ ./updated.py 8000 8004 8002 # Remove 8001, add 8004
httpd-8001: disappeared
httpd-8004: available
httpd-8001: stopped
httpd-8001: removed process group
httpd-8004: added process group
$ supervisorctl status
httpd-8000 RUNNING pid 31768, uptime 0:00:12
httpd-8002 RUNNING pid 31766, uptime 0:00:12
httpd-8004 RUNNING pid 31785, uptime 0:00:02
$
No comments:
Post a Comment