Supervisord: A Powerful Process Management Tool
It is no exaggeration to describe it as “powerful.” Born in the Python ecosystem, Supervisord has grown into a highly mature process management tool. With just some simple installation and configuration, you can turn any non-daemon process into a daemon. Any little utility scripts you’ve written can instantly get a fancy service-like upgrade.
As a quick explainer—why do we want to daemonize? Simply put, it elevates your program from the application layer to the service layer (regardless of whether your program natively behaves like a service).
Now, let’s get into the good stuff:
1. Installation
There are two recommended ways:
- Method A: Use
easy_install, a Python packaging utility that makes downloading, installing, and updating Python packages a breeze. If you already haveeasy_installinstalled, simply run the following in your terminal:1
easy_install supervisor
- Method B: If you don’t have
easy_installand don’t care to install it, go to http://pypi.python.org/pypi/supervisor to download the package, extract it, and install it manually:1
python setup.py install
For more installation methods, you can refer to the official docs at http://supervisord.org/installing.html.
2. Configuration
Run the following commands in your shell:
1 | echo_supervisord_conf > /etc/supervisord.conf |
If you want to enable the web-based monitoring dashboard, uncomment the following lines (remove the semicolons) in /etc/supervisord.conf:
1 | [inet_http_server] ; inet (TCP) server disabled by default |
3. Creating Process Configuration Files
To keep things modular and easy to maintain, all process-specific configurations should be saved in the /etc/supervisord.conf.d/ directory as *.conf files:
1 | vi /etc/supervisord.conf.d/yourprogram.conf |
Here is a configuration example:
1 | [program:yourprogram] |
For more detailed program settings, refer to the official configuration documentation: http://supervisord.org/configuration.html#program-x-section-settings
4. Running Supervisord
Simply run the command in your shell as root:
1 | supervisord |