Sovite.Core.Supervisor (sovite v0.6.0)

Copy Markdown View Source

Root supervisor of the Sovite MTA.

It loads and validates the configuration before starting anything. With an invalid config, the errors are logged and start_link/1 returns {:error, {:invalid_config, errors}}, so the MTA never runs with a half-valid setup.

To embed the MTA in another application, add it to that application's supervision tree:

children = [
  {Sovite.Core.Supervisor, config_path: "/etc/sovite/sovite.toml"}
]

Options

Children

In start order: the log file handler, the database (migrated before anything else starts), the cache of the domains in the database, the failed-login counter, the rate limiter, the caches of screened clients and suspended users, the greylist cleaner (with greylist.enabled), the certificate store and the ACME client (when TLS is configured), the MTA-STS policy cache (with mta_sts.enabled), the queue manager, the DMARC and TLS report senders (with dmarc.reports and tls_rpt.reports), the listeners, and the MTA-STS policy server (with mta_sts.serve). They stop in reverse order, so listeners close first.

When DANE is used, a task checks once at startup that the DNS resolver validates DNSSEC, and logs a warning if not: DANE then never applies.

Then, when enabled: the metrics (Sovite.Core.Metrics), the trace exporter (Sovite.Core.Tracing), the admin API listener (Sovite.Core.Web, the UI and admin API), the systemd watchdog, and last Sovite.Core.Control, which reloads the configuration on SIGHUP and drains the server when it stops.

Reloading

Sovite.Core.Control.reload/1 reads the config file again. Children whose options did not change keep running. Listeners take new options for new connections without closing their socket, when only their handler, PROXY protocol, or per-IP limit options changed; otherwise they are drained first. The queue manager takes its new options in place. Other children are restarted with theirs. Every child starts from the current configuration, so one that crashes after a reload comes back with the new options. Database and queue directory changes need a restart.

Socket activation

Under systemd socket activation (Sovite.Systemd.listen_fds/1), a listener whose address and port match an inherited socket uses it instead of opening its own.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts \\ [])

@spec start_link(keyword()) ::
  Supervisor.on_start()
  | {:error, {:invalid_config, list()} | {:queue_directory, File.posix()}}