service.shutdown

The Synapse service.shutdown tool can be used to initiate a graceful shutdown of a Synapse service.

Syntax

service.shutdown is executed using python -m synapse.tools.service.shutdown. The command usage is as follows:

python -m synapse.tools.service.shutdown -h

usage: synapse.tools.service.shutdown [-h] [--url URL] [--timeout TIMEOUT]
                                      [--no-drain]

Initiate a graceful shutdown of a service.

This tool is designed to put the service into a state where
any non-background tasks will be allowed to complete while ensuring
no new tasks are created. Without a timeout, it can block forever if
tasks do not exit.

When --no-drain is provided, promoted tasks are cancelled instead of
awaited, allowing the operator to bound shutdown wall time. Demote is still
attempted within the timeout; only the task-wait phase changes.

The --timeout value bounds the entire operation. Demote discovery, demote,
and task reaping share the single timeout value; no sub-phase may exceed
the time remaining when it starts.

Exit codes:
  0 - graceful shutdown was initiated successfully
  1 - the shutdown was aborted because the timeout was reached; the
      service may be in a partially shutdown state as a result of this
      timeout.
  2 - an unexpected error occurred

NOTE: This will also demote the service if run on a leader with mirrors.

options:
  -h, --help         show this help message and exit
  --url URL          The telepath URL to connect to the service.
  --timeout TIMEOUT  An optional timeout in seconds. If timeout is reached,
                     the shutdown is aborted.
  --no-drain         Cancel promoted tasks instead of awaiting them.

Note

This tool was previously run using synapse.tools.shutdown. It can still be run with that name.