Supervisord Official documentation
Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.
It can be used to manage any type of process, from custom python code to node.js application.
Examples
Node.js app
configuration: supervisord: programs: - name: api user: nobody command: node app.js env: NODE_ENV=prod,MANDRILL_API_KEY=qwerty extra: | directory = /opt/api autorestart = true
We here define a node.js application that will run as
nobody
user, execute theapp.js
code from the/opt/api
folder. It will restart automatically no matter how. BothNODE_ENV
andMANDRILL_API_KEY
environment variable will be passed along to the running process.Python app
configuration: supervisord: programs: - name: app user: nobody command: python /opt/my_app/app.py env: DEBUG=true
We here define a simple program that will execute
app.py
as nobody, passing theDEBUG
environment variable along.Custom app
configuration: supervisord: programs: - name: consul command: /bin/consul agent -config-dir /etc/consul.d/
We here define a simple program that will execute a custom command; in this case the
consul
agent as root.
Parameters
Supervisord has dozens of available options, but for improved user experience we only selected a few that we considered essential enough for having their dedicated devo.ps attribute. You can check below for the available options.
You can however extensively customize your program execution by using the extra
option. Note that with the Yaml
format of the server (and task), you need to use the proper "scalar" to maintain the proper new-line character.
supervisord:
programs:
...
extra: |
first = parameter
second = parameter
Note the |
after extra:
, it will ensure both lines below are effectively treated as lines (instead of space separated strings of a larger extra
string). See the official YAML documentation for more details about the scalars format.
Commands
- devops supervisord restart
- Restart the Supervisord service.
- devops supervisord start
- Start the Supervisord service if stopped.
- devops supervisord stop
- Stop the Supervisord service if running.
- devops supervisord program add
-
Add a new program to Supervisord.
Options
Name Type Description Required autostart boolean Choose whether the application should be executed automatically on start. command string Command to execute. It must be executed in foreground. Required env string Comma separated list of environment variables to provide to the command on execution. extra string Any parameter (line seperated) supported by Supervisord for the programs (http://supervisord.org/configuration.html#program-x-section-settings) log object Log related details. name string Name of the program to add. Required user string Running user for the command. - devops supervisord program remove
-
Remove an existing program from Supervisor.
Options
Name Type Description Required name string Name of the program to remove. It should match one that was previously created. Required - devops supervisord program restart
-
Restart a program managed by Supervisord.
Options
Name Type Description Required name string Name of the program to restart. Required - devops supervisord program start
-
Start a program managed by Supervisord.
Options
Name Type Description Required name string Name of the program to start. Required - devops supervisord program stop
-
Stop a program managed by Supervisord.
Options
Name Type Description Required name string Name of the program to stop. Required
Configuration
- configuration:
- inet.password string
- The password required for authentication to this HTTP server. This can be a cleartext password, or can be specified as a SHA-1 hash if prefixed by the string {SHA}
- inet.port string
- A TCP host:port value or (e.g. `127.0.0.1:9001`) on which Supervisord will listen for HTTP/XML-RPC requests
- inet.username string
- Username required for authentication to this HTTP server.
- nodaemon boolean
- Define whether or not run the Supervisord service as a daemon or not
- programs array
- array of programs managed by Supervisord
- program.autostart boolean
- Choose whether the application should be executed automatically on start.
- Default:
true
- program.command string
- Command to execute. It must be executed in foreground.
- Required
- program.env string
- Comma separated list of environment variables to provide to the command on execution.
- program.extra string
- Any parameter (line seperated) supported by Supervisord for the programs (http://supervisord.org/configuration.html#program-x-section-settings)
- program.log object
- Log related details.
- program.log.stderr string
- Path to the log file that will save the command stderr
- program.log.stdout string
- Path to the log file that will save the command stdout
- program.name string
- Name of the program to add.
- Required
- program.user string
- Running user for the command.
- Default:
root