Supervisor

Introduction

Supervisor is a client/server-based system that allows users to manage processes on Unix-like operating systems. It is configured using simple text files and enables you to start, stop, and monitor processes in various ways without superuser privileges.


With certain pre-installed packages from our Marketplace, such as Shopware, Supervisor is already pre-installed by default. If Supervisor is not available on your server, it can be installed by our support team as part of the “Managed” support level. For unmanaged servers, you can perform the installation yourself, for example, using the package manager of the respective distribution.



Comparison to systemd

Supervisor is a lightweight tool primarily used to keep user-defined processes running and to automatically restart them in the event of a crash—ideal for simple applications or containers.\systemd, on the other hand, is a complete init and service management system that controls not only processes but also dependencies, boot sequences, logging, and security, and is the standard on most modern Linux distributions.


Advantages Supervisor systemd
Centralized management*
Simplified administration
Process management**
Deployment integration
Web interface***

* Centralized management possible via our configuration module

** Additional processes can be started very quickly as needed

*** A web interface can be made available after configuration



Features of Supervisor

Centralization

In a traditional configuration—such as using cron jobs—there is a risk that processes will not automatically restart after a termination and thus will not run reliably. Supervisor manages applications as subprocesses and can be configured to start them at system boot and automatically restart them in the event of a crash.

The subprocesses are not started as daemons, but directly via fork/exec. This allows Supervisor to immediately receive a signal from the operating system when a process terminates—unlike solutions that rely on PID files and periodic polling to detect crashed processes.


Extensibility

Supervisor features an event notification protocol that can be used by programs and scripts written in any programming language for monitoring purposes. In addition, it offers an XML-RPC interface for control and can be further customized through extensions implemented in Python.


Compatibility

Supervisor is fully implemented in Python and runs on nearly all operating systems except Windows. It is officially tested and supported on Linux, macOS, Solaris, and FreeBSD.


Process Groups and Priorities

In some cases, it is necessary to start processes in groups or according to priority. Supervisor allows you to assign processes to different priority groups so that they are automatically started via supervisorctl using commands such as start all or restart all, according to their priority. Alternatively, processes can also be grouped into logical groups, which can then be started or stopped as a single unit.



Management in the Customer Center

Through the Customer Center, you can modify Supervisor configuration files even without direct access to the shell. You can find the configuration under the “Configuration Files” tab in Server Management. For Managed Servers, a Supervisor configuration for the respective application is already stored here.


Example Configuration

A simple Supervisor configuration file that runs a PHP script via the console might look like this, for example:


[program:demoscript]
process_name=%(program_name)s_%(process_num)02d
numprocs=1
command=php /var/www/demoscript.php --time-limit=120 --memory-limit=512M
environment=VARIABLE="demo_script_%(process_num)02d"
user=demouser
autostart=true
autorestart=true
startsecs=0
stopwaitsecs=3600
redirect_stderr=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log


Various variables are used here to control supervisor. For example, the variable numprocs represents the number of processes to be started, and the variable user represents the user in whose context the command is executed. Complete documentation for each variable can be found in Supervisor’s online help or by running the man supervisor command.



Logging

The output of each program executed by supervisor to stdout and stderr can be redirected to a corresponding log file, for example, to perform further analysis or error tracking. This can be configured in the job’s configuration file.


Web Interface


The web interface is disabled by default. It should only be enabled in private, secure environments and must never be accessible from the public Internet. Access is unencrypted.

A simple web interface allows you to control the Supervisor jobs and view the log files. The configuration for this is specified in the [inet_http_server] section of the Supervisor configuration. Details can be found in the official Supervisor documentation.


An example configuration might look like this:

[inet_http_server]
port = 127.0.0.1:9001
username = user
password = 123




Using supervisorctl


On Managed Servers, the connection to supervisorctl is always established via the SSH system user. This is different from any existing SSH user managed by the Plesk Control Panel.

With supervisorctl, you can monitor, activate, and deactivate existing supervisor jobs via the command line. It thus serves as an alternative to the web interface described earlier.


The Most Important supervisorctl CLI Commands

Command Description
status Lists the currently running jobs and their PIDs
avail Lists the jobs stored in the configuration files
start / stop Explicitly starts or stops the respective job
add / remove Removes the job from the list of jobs to be executed
help Complete overview of all available commands