Supervisor
Supervisor allows its users to monitor and control a number of services on a server. A service, or daemon, is a program that starts automatically and is kept in the background. In case it quits or crashes, it is restarted by supervisord.
Supervisor shares some of the same goals of programs like launchd, daemontools, and runit. It is meant to be used to control processes related to a project or a customer, and is meant to start like any other program at boot time.
Create a service
To create a new service, place an .ini file for each new service in ~/etc/services.d/.
For example, if you want to add a service called my-application that runs and monitors an executable located at /home/customer/bin/my-application, place the file my-application.ini in ~/etc/services.d/ and edit it:
[program:my-application]
command=/home/customer/bin/my-application
startsecs=60
Afterwards, ask supervisord to look for the new my-application.ini file:
[customer@futura ~]$ supervisorctl reread
my-application: available
And then start your daemon:
[customer@futura ~]$ supervisorctl update
my-application: added process group
Start and stop a service
To start a non-running service or stop a running one, use supervisorctl start my-application and supervisorctl stop my-application. To restart a service, you can also use supervisorctl restart my-application.
[customer@futura ~]$ supervisorctl start my-application
my-application: started
[customer@futura ~]$ supervisorctl stop my-application
my-application: stopped
[customer@futura ~]$ supervisorctl restart my-application
my-application: stopped
my-application: started
Remove a service
To remove a service, you need to stop it first, then you can remove it using supervisorctl:
[customer@futura ~]$ supervisorctl stop my-application
my-application: stopped
[customer@futura ~]$ supervisorctl remove my-application
my-application: removed process group
List all services
To get an overview of your services and their current status, run supervisorctl status:
[customer@futura ~]$ supervisorctl status
my-application RUNNING pid 12849, uptime 0:02:41
Logging
supervisord logs are stored in ~/logs/. You can use supervisorctl tail my-application and supervisorctl tail my-application stderr to view the log for my-application. Type in supervisorctl tail to see available options.