Friday, October 9, 2015

Supervisor program groups

"Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems."
Simply put, it's a program that can run other programs for you. It does its job, it is mature and straightforward - just define your programs in a plain Windows-INI-style configuration file (although Supervisor doesn't run on Windows) and you're set.

But what if you've got a whole bunch of programs to run, isn't starting/restarting/stopping them one-by-one using supervisorctl going to be a major hassle? Yes, but Supervisor offers a solution: program groups! Define your programs as usual, but add a group entry to the conf file:

[program:a-program]
command=command-to-run-a-program
; etc.

[program:another-program]
command=command-to-run-another-program
; etc.

[program:yet-another-program]
command=command-to-run-yet-another-program
; etc.

[group:my-group]
programs=a-program,another-program,yet-another-program

Now, instead of issuing commands for each program like so:
supervisorctl start a-program
supervisorctl start another-program
supervisorctl start yet-another-program
or
supervisorctl restart a-program
supervisorctl restart another-program
supervisorctl restart yet-another-program
or
supervisorctl stop a-program
supervisorctl stop another-program
supervisorctl stop yet-another-program

you can just do
supervisorctl start my-group:*
or
supervisorctl restart my-group:*
or
supervisorctl stop my-group:*

And just imagine having 10 or 20 or even more programs to control!

No comments:

Post a Comment