Supervisor

Foreword

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


With certain pre-installations from our Marketplace, such as Shopware, Supervisor is already pre-installed as standard. If Supervisor is not available on your server, it can be installed by our support team at the "Managed" support level. For unmanaged servers, you can carry out the installation yourself, e.g. via the package manager of the respective distribution.



Comparison to systemd

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


Advantages Supervisor systemd
Central administration*
Simplified administration
Process management***
Deployment integration
web interface****

* Central management possible via our configuration module

** Additional processes can be started within a very short time if required

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



Features of Supervisor

Centralization

With a classic configuration, e.g. via cronjobs, there is a risk that processes are not restarted automatically after an abort and are therefore not executed reliably. Supervisor manages applications as sub-processes and can be configured so that it starts them at system startup and restarts them automatically in the event of a crash.

The subprocesses are not started as daemons, but directly via fork/exec. This means that Supervisor immediately receives a signal from the operating system when a process ends - in contrast to solutions that rely on PID files and periodic polling to detect crashed processes.


Extensibility

Supervisor has an event notification protocol that can be used by programs and scripts in any programming language for monitoring. 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 almost 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 makes it possible to assign different priority groups to processes so that they are automatically started according to their priority via supervisorctl with commands such as start all or restart all. Alternatively, processes can also be combined into logical groups, which can then be started or stopped as a unit.



Administration in the customer center

You can use the customer center to change supervisor configuration files without direct access to the shell. The configuration can be found in the "Configuration files" tab in the server administration. For managed servers, a supervisor configuration for the respective application is already stored here.

Example: Configuration of a Shopware standard installation](/api/attachments.redirect?id=301a0a7f-05a5-4fa4-be71-803b3f89cbc3 " =1896x779")


Example configuration

A simple supervisor configuration file that is used to call a PHP script via the console could 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 to control supervisor. For example, the variable numprocs stands for the number of processes to be started or the variable user for the user in whose context the command is executed. A complete documentation of the individual variables can be found in the online help of Supervisor or with the command man supervisor.



Logging

The output of the respective program executed by supervisor on stdout and stderr can be redirected to a corresponding log file, e.g. to carry out further analyses or error tracking. This can be set in the configuration file of the job.


Web interface


The web interface is deactivated by default. It should only be activated in private, protected environments and should never be accessible from the open Internet. Access is unencrypted.

The supervisor jobs can be controlled and the log files viewed using a simple web interface. This is configured in the [inet_http_server] section of the Supervisor configuration. Details can be found in the official Supervisor documentation.


An example configuration could look like this:

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


Overview of the supervisor web interface



Use of the supervisorctl


The connection to supervisorctl is always made via the SSH system user for managed servers. This is different from any existing SSH user that is managed by the Plesk Control Panel.

With supervisorctl you have the possibility to monitor, activate and deactivate existing supervisor jobs via the command line. It is therefore an alternative to the web interface already presented.


The most important supervisorctl CLI commands

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