Skip to main content

Dependency support when starting Supervisor services

supervisord-dependent-startup is a plugin for Supervisor that allows starting up services after dependent services have reached specific states. This plugin is based on ordered-startup-supervisord by Jason Corbett.

The Problem

The problem can be seen in supervisor bug #122. The priority order in supervisor does determine startup order, but when autostart=true supervisor doesn't wait for the previous process to be RUNNING in order to continue. What is even harder is having initialization scripts that need to exit before continuing. This software is meant to make this one use case easier.

How it works

This is an event listener for supervisor. This means it is run by supervisor on startup and supervisor will send it messages whenever a service reaches a particular process state. When configured it will wait till a supervisor subprocess gets to the configured state before starting dependent services.

Caveats

The plugin does not start groups. It can start services that are part of a group, but it won't directly start a group.

Installing

# From pypi
pip install supervisord-dependent-startup

# From github:
pip install -e git+https://github.com/bendikro/supervisord-dependent-startup.git#egg=supervisord-dependent-startup

Configuration

Configuration requires several things. First you need to configure supervisord-dependent-startup as an event listener by adding the following to supervisor.conf:

[eventlistener:dependentstartup]
command=python -m supervisord_dependent_startup
autostart=true
autorestart=unexpected
startretries=0
exitcodes=0,3
events=PROCESS_STATE

A working /etc/supervisor.conf can look like this:

[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)

[supervisord]
logfile=/tmp/supervisord.log
loglevel=info
pidfile=/var/run/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

[eventlistener:dependentstartup]
command=python -m supervisord_dependent_startup
autostart=true
autorestart=unexpected
startretries=0
exitcodes=0,3
events=PROCESS_STATE

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

Service configuration options

There are three configuration options for a service ([program:*]) to control how it is processed by supervisord-dependent-startup

dependent_startup

Mark this service to be handled by supervisord-dependent-startup. This must be set to true for all services that depend on other services or is being depended on by other services.

Type bool
Required yes
Note When setting this to true, autostart must be set to false

dependent_startup_wait_for

Specify the services this service depends on before in can be started.

Type str
Required no
Format dependent_startup_wait_for=<parent-service>:<state[,state[..]]> [..]
Note state must one or more comma separated values of: starting, running, backoff, stopping, exited, fatal
Example with one dependency

To have a service named child depend on a service parent: dependent_startup_wait_for=parent:running

Example with two dependencies

Multiple dependencies are separated by a white space. To have a service named child depend on the services parent1 and parent2: dependent_startup_wait_for=parent1:running parent2:running

dependent_startup_inherit_priority

Specify if the service should inherit its priority from the services it depends on.

Type bool
Required no
Example dependent_startup_inherit_priority=true

Building and testing

Run tests

python setup.py test

Create source dist

python setup.py sdist

Run tests and code syntax check

tox

Metadata

Release files for supervisord-dependent-startup 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for supervisord-dependent-startup 1.4.0
File Size Uploaded Provenance Actions
supervisord-dependent-startup-1.4.0.tar.gz 35.1 kB Without provenance Details for supervisord-dependent-startup-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for supervisord-dependent-startup 1.4.0
File Interpreter ABI Platform Actions
supervisord_dependent_startup-1.4.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for supervisord_dependent_startup-1.4.0-py2.py3-none-any.whl

Total release size: 73.4 kB

Release files / supervisord-dependent-startup-1.4.0.tar.gz

Download URL supervisord-dependent-startup-1.4.0.tar.gz
Size 35.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bc45bd4c7a4a68a35ddf505046d203cb076c35512650af230d156a0570e74813
BLAKE2b-256 checksum
How to use checksums
8bf24daab0e3d8d7062cc89689b32410634b969672aacfeb1228ae503e7296b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.14

Release files / supervisord_dependent_startup-1.4.0-py2.py3-none-any.whl

Download URL supervisord_dependent_startup-1.4.0-py2.py3-none-any.whl
Size 38.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
143a42bcf102010691a8d461d49c3e56ea46aa09e422dabed2b4890ecc67f4d9
BLAKE2b-256 checksum
How to use checksums
0e66d386c3d2cf36846ded0b9f4999a6c59fd04fb15d768e59d3acfa039102bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.14

Security for supervisord-dependent-startup 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page