Skip to content

supervisorctl Operations

Manage processes controlled by supervisord using supervisorctl.

Every operation accepts the global supervisorctl options: config_file (-c), server_url (-s), username (-u) and password (-p).

The read-only supervisorctl actions are facts, not operations: status maps to pyinfra.facts.supervisorctl.SupervisorctlStatus and pid to SupervisorctlPid / SupervisorctlPids. The interactive actions (tail, fg, help) are not covered.

Facts used in these operations: supervisorctl.SupervisorctlStatus.

supervisorctl.add

Stateless operation

This operation will always execute commands and is not idempotent.

Activate any updates in config for a process or group.

supervisorctl.add(
         group: 'str',
         config_file: 'str | None' = None,
         server_url: 'str | None' = None,
         username: 'str | None' = None,
         password: 'str | None' = None,
         **kwargs,
    )
  • group: name of the process group to add
  • config_file: configuration file to pass to supervisorctl (-c)
  • server_url: URL on which supervisord listens (-s)
  • username: username to authenticate with (-u)
  • password: password to authenticate with (-p)

Global arguments

This operation also inherits all global arguments.

supervisorctl.clear

Stateless operation

This operation will always execute commands and is not idempotent.

Clear the log files of a process.

supervisorctl.clear(
         process: 'str',
         config_file: 'str | None' = None,
         server_url: 'str | None' = None,
         username: 'str | None' = None,
         password: 'str | None' = None,
         **kwargs,
    )
  • process: name of the process, or all to clear every process' logs
  • config_file: configuration file to pass to supervisorctl (-c)
  • server_url: URL on which supervisord listens (-s)
  • username: username to authenticate with (-u)
  • password: password to authenticate with (-p)

Global arguments

This operation also inherits all global arguments.

supervisorctl.process

Manage the state of supervisor processes.

supervisorctl.process(
         process: 'str',
         running: 'bool | None' = True,
         restarted: 'bool' = False,
         command: 'str | None' = None,
         config_file: 'str | None' = None,
         server_url: 'str | None' = None,
         username: 'str | None' = None,
         password: 'str | None' = None,
         **kwargs,
    )
  • process: name of the process to manage, a single <name>, a group <gname>:* or all
  • running: whether the process should be running
  • restarted: whether the process should be restarted
  • command: custom supervisorctl action to run like: supervisorctl <command> <process>
  • config_file: configuration file to pass to supervisorctl (-c)
  • server_url: URL on which supervisord listens (-s)
  • username: username to authenticate with (-u)
  • password: password to authenticate with (-p)

Processes in BACKOFF, FATAL or UNKNOWN state are considered not running.

Examples:

from pyinfra.operations import supervisorctl

supervisorctl.process(
    name="Start the web process",
    process="web",
    running=True,
)

supervisorctl.process(
    name="Restart every process in the workers group",
    process="workers:*",
    restarted=True,
)

Global arguments

This operation also inherits all global arguments.

supervisorctl.reload

Stateless operation

This operation will always execute commands and is not idempotent.

Restart the remote supervisord.

supervisorctl.reload(
         config_file: 'str | None' = None,
         server_url: 'str | None' = None,
         username: 'str | None' = None,
         password: 'str | None' = None,
         **kwargs,
    )
  • config_file: configuration file to pass to supervisorctl (-c)
  • server_url: URL on which supervisord listens (-s)
  • username: username to authenticate with (-u)
  • password: password to authenticate with (-p)

Global arguments

This operation also inherits all global arguments.

supervisorctl.remove

Stateless operation

This operation will always execute commands and is not idempotent.

Remove a process or group from the active configuration.

supervisorctl.remove(
         group: 'str',
         config_file: 'str | None' = None,
         server_url: 'str | None' = None,
         username: 'str | None' = None,
         password: 'str | None' = None,
         **kwargs,
    )
  • group: name of the process group to remove
  • config_file: configuration file to pass to supervisorctl (-c)
  • server_url: URL on which supervisord listens (-s)
  • username: username to authenticate with (-u)
  • password: password to authenticate with (-p)

Global arguments

This operation also inherits all global arguments.

supervisorctl.reread

Stateless operation

This operation will always execute commands and is not idempotent.

Reload the supervisord configuration files, without adding, removing or restarting anything.

supervisorctl.reread(
         config_file: 'str | None' = None,
         server_url: 'str | None' = None,
         username: 'str | None' = None,
         password: 'str | None' = None,
         **kwargs,
    )
  • config_file: configuration file to pass to supervisorctl (-c)
  • server_url: URL on which supervisord listens (-s)
  • username: username to authenticate with (-u)
  • password: password to authenticate with (-p)

Global arguments

This operation also inherits all global arguments.

supervisorctl.signal

Stateless operation

This operation will always execute commands and is not idempotent.

Send a signal to a supervisor process.

supervisorctl.signal(
         signal: 'str',
         process: 'str',
         config_file: 'str | None' = None,
         server_url: 'str | None' = None,
         username: 'str | None' = None,
         password: 'str | None' = None,
         **kwargs,
    )
  • signal: signal to send, eg HUP or USR2
  • process: name of the process to signal, a single <name>, a group <gname>:* or all
  • config_file: configuration file to pass to supervisorctl (-c)
  • server_url: URL on which supervisord listens (-s)
  • username: username to authenticate with (-u)
  • password: password to authenticate with (-p)

Example:

from pyinfra.operations import supervisorctl

supervisorctl.signal(
    name="Rotate web process logs",
    signal="USR2",
    process="web",
)

Global arguments

This operation also inherits all global arguments.

supervisorctl.update

Stateless operation

This operation will always execute commands and is not idempotent.

Reload the supervisord configuration files, add/remove process groups as necessary and restart affected programs.

supervisorctl.update(
         groups: 'list[str] | None' = None,
         config_file: 'str | None' = None,
         server_url: 'str | None' = None,
         username: 'str | None' = None,
         password: 'str | None' = None,
         **kwargs,
    )
  • groups: optional list of process groups to update, defaults to all
  • config_file: configuration file to pass to supervisorctl (-c)
  • server_url: URL on which supervisord listens (-s)
  • username: username to authenticate with (-u)
  • password: password to authenticate with (-p)

Example:

from pyinfra.operations import supervisorctl

supervisorctl.update(
    name="Apply config changes to the workers group",
    groups=["workers"],
)

Global arguments

This operation also inherits all global arguments.