Sovite.Core.Control (sovite v0.6.0)

Copy Markdown View Source

Runs the MTA as a whole: reloads the configuration, drains the server before it stops, and reports its status. Started last by Sovite.Core.Supervisor, so it stops first.

Reload

reload/1, SIGHUP, sovitectl config reload, and systemctl reload sovite read the config file again and apply it without stopping (see "Reloading" in Sovite.Core.Supervisor). An invalid file changes nothing: the errors are returned and logged.

Drain

When the MTA stops (SIGTERM, systemctl stop), the SMTP listeners stop accepting connections, idle sessions are closed with 421, and sessions in a transaction get to finish it; no new deliveries start, and the running ones get to end. After server.shutdown_timeout, whatever is left is cut off: messages being delivered stay queued and are delivered after the next start.

systemd

Under systemd (Type=notify), the service manager is told when the MTA is ready, reloading, and stopping, with a status line.

Telemetry

  • [:sovite, :config, :reloaded] - %{}, %{path, changed}: changed is the IDs of the children that were started, updated, restarted, or stopped.
  • [:sovite, :config, :reload_failed] - %{}, %{path, reason}.
  • [:sovite, :server, :drain, :start] - %{connections}, %{}.
  • [:sovite, :server, :drain, :stop] - %{duration, connections}, %{deliveries} (:ok or :timeout). connections is the number of SMTP connections still open.

Summary

Functions

Drains the server, see the module docs. Returns when done.

The listeners of supervisor and their open connections, as {id, count}.

Reloads the config file. Returns :ok, {:error, errors} with the Sovite.Core.Config.Errors of an invalid file, or {:error, reason} for a change that needs a restart ({:restart_required, keys}) or a server started without a config file (:no_config_file).

The status of the MTA: version, host name, start time, config file and last reload, listeners and their connections, queue sizes, and deliveries.

Functions

drain(control)

@spec drain(GenServer.server()) :: :ok

Drains the server, see the module docs. Returns when done.

listener_connections(supervisor)

@spec listener_connections(Supervisor.supervisor()) :: [
  {String.t(), non_neg_integer()}
]

The listeners of supervisor and their open connections, as {id, count}.

reload(control)

@spec reload(GenServer.server()) :: :ok | {:error, term()}

Reloads the config file. Returns :ok, {:error, errors} with the Sovite.Core.Config.Errors of an invalid file, or {:error, reason} for a change that needs a restart ({:restart_required, keys}) or a server started without a config file (:no_config_file).

status(control)

@spec status(GenServer.server()) :: map()

The status of the MTA: version, host name, start time, config file and last reload, listeners and their connections, queue sizes, and deliveries.