Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (53 sloc) 2.33 KB

supervisord

We use supervisord to monitor services. 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.

Create a Service

To create a new service, place a .ini file for each new service in ~/etc/services.d/. So if you want to add a service called my-daemon that runs an executable located at /home/eliza/bin/my-daemon, place the file my-daemon.ini in ~/etc/services.d/ and edit it:

[program:my-daemon]
command=/home/eliza/bin/my-daemon
autostart=yes
autorestart=yes

Afterwards, ask supervisord to look for new .ini files:

[eliza@doolittle ~]$ supervisorctl reread
my-daemon: available

And then start your daemon:

[eliza@doolittle ~]$ supervisorctl update
my-daemon: added process group

Start / Stop a Service

To start a non-running service or stop a running one, use supervisorctl start my-daemon and supervisorctl stop my-daemon. To restart a service, you can also use supervisorctl restart my-daemon.

[eliza@doolittle ~]$ supervisorctl start my-daemon
my-daemon: started
[eliza@doolittle ~]$ supervisorctl stop my-daemon
my-daemon: stopped
[eliza@doolittle ~]$ supervisorctl restart my-daemon
my-daemon: stopped
my-daemon: started

Remove a Service

To remove a service, you need to stop it first, then you can remove it using supervisorctl:

[eliza@doolittle ~]$ supervisorctl stop my-daemon
my-daemon: stopped
[eliza@doolittle ~]$ supervisorctl remove my-daemon
my-daemon: removed process group

List Services

To get an overview of your services and their current status, run supervisorctl status:

[eliza@doolittle ~]$ supervisorctl status
my-daemon                              RUNNING   pid 16337, uptime 0:00:04

Logging

supervisord logs are stored in ~/logs/. You can use supervisorctl tail my-daemon to view the log for my-daemon.

Further Reading

You can’t perform that action at this time.