Operations 16 min read

Using Supervisor for Process Monitoring and Management on Unix-like Systems

This article introduces Supervisor, a client‑server process monitoring tool for Unix-like systems, explains why it solves persistent process deployment issues, walks through installation, configuration, command‑line usage, advanced features such as process groups and auto‑restart policies, and provides code examples for practical implementation.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Using Supervisor for Process Monitoring and Management on Unix-like Systems

Supervisor is a client/server process monitoring and management tool for Unix-like operating systems, designed to improve the stability of long‑running background services such as API servers or consumer processes.

Problem scenario : Deploying persistent processes with nohup cmd & can lead to unexpected termination, causing service interruptions.

Supervisor addresses this by automatically restarting failed processes and supporting grouped management.

Installation

pip install supervisor

Note: Supervisor does not support Windows.

Configuration

Generate a base configuration file: echo_supervisord_conf > /etc/supervisord.conf Key sections include [unix_http_server], [supervisord], [supervisorctl], and optional [include] to load additional program files.

Create a directory for individual program configs and enable inclusion:

mkdir /etc/supervisord.d
[include]
files = /etc/supervisord.d/*.ini

Example program configuration for a Python script test.py:

[program:test]
command=python -u ./test.py
directory=/root/test/
redirect_stderr=true
stdout_logfile=/root/test/test.log

Link the program file into the include directory:

ln ./supervisor-test.ini /etc/supervisord.d/supervisor-test.ini

Running Supervisor

Start the daemon: supervisord Control processes with supervisorctl (e.g., status, start, stop, restart, signal).

Advanced Features

Process groups allow batch operations:

[group:test]
programs=test-task_service, test-collector

Use commands like stop test: to affect all members of the group.

Program options such as command, directory, numprocs, autostart, stdout_logfile, and redirect_stderr provide fine‑grained control.

Auto‑restart policy is governed by autorestart (values: true, false, unexpected) and exitcodes. Experiments show that processes exiting with unexpected codes or being killed are automatically restarted, while normal exits are not.

Start‑up verification uses startsecs to determine if a process has started successfully; failures within this window trigger back‑off and eventual FATAL status.

Web interface can be enabled via [inet_http_server] for visual management, but should be secured.

Conclusion

Supervisor offers a robust solution for managing persistent services, supporting configuration inheritance, process grouping, signal handling, and customizable restart behavior, making it a valuable tool for system administrators and DevOps engineers.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxSystem AdministrationSupervisorprocess monitoring
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.