Skip to main content

HOT RELOAD

Overview

swamp serve reload makes a running server re-read its extensions, the trusted collectives list and its config file, serve.yaml, without stopping. Each serve.yaml setting the reload changed is reported as applied, needing a restart, or overridden by a startup flag or environment variable. See What reload changes.

A server reloads on any of three triggers, which reload the same things:

  • swamp serve reload --server <url>, an admin-only request over WebSocket. It works on every server.
  • SIGHUP, sent by swamp serve reload without --server, by kill -HUP $(cat .swamp/serve.pid), or by systemd's ExecReload. See When SIGHUP reloads.
  • The config poller of a managed config deployment.

A reload never changes what is already running. New values govern new runs, requests, WebSocket connections and enrollments.

When SIGHUP reloads

SIGHUP reloads a server that is not attached to a terminal, such as a daemon, a container or a systemd service, and a server started with --hot-reload. A server running in a terminal without --hot-reload keeps SIGHUP as shutdown, so closing the terminal still stops it. Reload such a server with --server.

Subcommand

swamp serve reload

Without --server, reads .swamp/serve.pid and sends SIGHUP to that process. The command does not wait for the result: the server log lists what the reload applied. Reload with --server to see the report in the terminal.

Before signalling, the command checks the PID file:

Check Result
No PID file Refused; reload with --server
No process has that PID Refused as a stale PID file
The process started at another time and is not swamp serve Refused as a stale PID file
The start time cannot be confirmed (no ps, an older serve, a clock step since startup) Warns, then sends SIGHUP
The process matches Sends SIGHUP

Only one reload runs at a time. A reload requested while another is in progress is refused.

Remote reload

swamp serve reload --server <url>

Sends a reload request to a running swamp serve instance over WebSocket and prints its report. The caller must be an admin.

Flags

Flag Description
--server <url> WebSocket URL of the running serve instance (env: SWAMP_SERVE_URL)
--token <token> Server token for authentication. Only applies with --server. Falls back to stored credential or SWAMP_SERVER_TOKEN
--token-file <path> File holding the server token; mutually exclusive with --token (env: SWAMP_SERVER_TOKEN_FILE)
--ca-cert <path> PEM CA certificate to trust for TLS connections to the server (env: SWAMP_CA_CERT)
--repo-dir <dir> Repository directory for a local reload (env: SWAMP_REPO_DIR). Not accepted with --server

Credential resolution

When --token is not provided, the client resolves credentials in this order:

  1. SWAMP_SERVER_TOKEN environment variable
  2. Stored credential for the server URL in ~/.config/swamp/servers.json (written by swamp auth server-login)

Exit status

Outcome Exit
Reload succeeded, including settings reported needing a restart 0
The server refused serve.yaml (configRejected: true) 1
The extension reload failed on the server 1
No PID file, a stale PID file, or the server is unreachable 1

A CI step that edits serve.yaml and reloads sees a refused file as a failure.

Examples

# Reload on a remote server with explicit token
swamp serve reload --server wss://swamp.acme.internal:9090 \
  --token 'paul-token.<secret>'

# Reload using stored credential
swamp serve reload --server wss://swamp.acme.internal:9090

# Reload using SWAMP_SERVE_URL (no --server needed)
export SWAMP_SERVE_URL=wss://swamp.acme.internal:9090
swamp serve reload

PID file

File Contents
.swamp/serve.pid The bare process ID, for kill -HUP and systemd's PIDFile=
.swamp/serve.pid.json The process ID, its start time and the executable name

Both are written whenever SIGHUP reloads (see When SIGHUP reloads), relative to the repository root, and removed at shutdown while they still name this process. A server that cannot write them logs a warning and reloads only over --server; with --hot-reload, the failure stops startup instead.

What reload changes

A reload re-reads serve.yaml with the checks startup runs, and merges it with the startup flags and environment variables exactly as startup does. If the file fails a check, nothing in it is applied, the report sets configRejected: true, and swamp serve reload --server exits 1. Extensions are still reloaded.

Otherwise each changed setting falls into one of four classes:

  • Applied: in force when the reload returns.
  • Needs a restart: reported with the reason, and left as it was.
  • Overridden: pinned by a startup flag or environment variable. Change the flag or variable and restart.
  • Startup-only: read once at startup and not reported.

A setting that is only partly applied, such as a list that gained one name it cannot look up yet, is listed under both applied and needs a restart.

Applied on reload

Setting Notes
dashboard, enable-internal-api
max-concurrent-runs, max-runs-per-principal, max-run-duration, max-concurrent-webhook-runs, max-signal-wait-timeout A lowered limit stops no run in flight
queue-timeout, ws-idle-timeout, shutdown-drain-timeout, shutdown-listener-grace, auto-resume
trust-proxy, trusted-hosts, dispatch-env-allow, verify-on-enroll
schedule, max-concurrent-scheduled-runs, triggers See Scheduling and timed services
webhooks, webhook-routes-dir, webhook-routes-poll See Webhook routes
reconciliation-interval, datastore-poll-interval, continuation-sweep-interval, token-gc-interval, token-gc-grace-period, auth.group-refresh-interval See Scheduling and timed services
auth.allowed-users, auth.allowed-collectives, auth.groups-field, auth.restricted-model-types, auth.restricted-commands See Access lists
auth.admins Removals only. See Admins
grant-reload, grants-file, grants-dir, auth.approve-requires-explicit-grant, auth.signal-requires-explicit-grant, auth.tag-requires-explicit-grant See Grants
audit.policy, audit.alerts, audit.fail-open, audit.sinks Each alert rule's window starts again

Needs a restart

Setting Reason
port, host, reuse-port The listener is bound to it
tls.cert-file, tls.key-file, tls.ca-cert The listener and TLS connections are set up with it
address, advertise-address It names this serve in the datastore, and peers learned it
auth.mode The auth mode decides which services run
auth.oauth-provider, auth.oauth-client-id, auth.oauth-client-name, auth.keep-oauth-client-in-vault Serve registered its OAuth client with it
Adding a name to auth.admins Serve writes new admin grants only at startup
heartbeat-interval, stale-ttl Every instance judges its peers' liveness by it
remote-only Every step of a running run reads it
hot-reload The signal handler is installed at startup
Turning audit on or off; audit.stores, audit.wal, audit.hmac, audit.batch-size, audit.flush-interval The audit chain and its WAL are opened at startup

The datastore (in .swamp.yaml) and the token-secrets block also need a restart.

Startup-only

--webhook flags, hydration-timeout and detach-runs are read once at startup. A reload ignores a change to them and does not report it.

Scheduling and timed services

  • schedule: turning scheduling off stops new fires. Queued scheduled runs stay pending for replay, and runs in flight finish and stay cancellable. Turning it on starts a scheduler with the reloaded triggers, then replays this process's pending scheduled runs and catches up missed fires. In a team, replay and catch-up run only on the node that leads scheduled fires; a follower that turned scheduling on does them when it takes the lead.
  • triggers: on a server with scheduling off, trigger changes are reported as needing a restart. A reload that also turns schedule on applies them.
  • max-concurrent-scheduled-runs: a raised limit starts queued scheduled runs at once. A lowered one stops no run in flight.
  • Intervals: a changed interval re-arms its service at once, counting from the reload, rather than after the timer already set.
  • On and off: group refresh, server token GC, the continuation sweep and the webhook routes poller start or stop on reload, under the leader rules startup applies. Nothing starts once shutdown has begun.

A timed service that cannot run on this server is reported as needing a restart, with a reason:

Setting Reported when
datastore-poll-interval No datastore poller runs on this serve
reconciliation-interval No reconciliation loop runs on this serve
auth.group-refresh-interval Group refresh runs only with --auth-mode oauth and an OAuth client secret
continuation-sweep-interval The sweep runs only at boot on this datastore, the datastore has no shared control-plane store, or boot hydration did not finish

Access lists

These apply with --auth-mode oauth.

  • Removing a name from auth.allowed-users takes effect on reload.
  • A new name is admitted once it resolves, from the stored name map or by a lookup through the club API key (SWAMP_API_KEY or --club-api-key-file). Until then it is reported, not admitted, and retried on each reload. One reload looks up at most 200 new names, within 60 seconds.
  • A name the provider does not know is skipped for good, as at startup.
  • A list that removals leave with no admitted name, and no auth.allowed-collectives, admits only the admins until it is fixed.
  • A changed auth.allowed-collectives re-registers the instance with Swamp Club. auth.groups-field and the restrictions apply as written.

Admission is per instance. Another instance keeps its own lists until it reloads.

Grants

  • The three explicit-grant rules apply to the next access decision.
  • grant-reload starts or pauses the grants poller. Switching to auto reconciles the grant sources first.
  • A changed grants-file or grants-dir is read with startup's checks. A source startup would refuse refuses the whole reload, and the stored grants stay in force. A source that passes is reconciled after the reload, in manual mode too.
  • A new source the reconcile held back, such as a grant naming a username that does not resolve, is reported as partly applied.

Admins

  • Removing a name from auth.admins revokes that admin's grant and reloads the policy before the report says applied. With a closed allowed-users list, it also re-plans admission, which admits only the admins.
  • Adding a name needs a restart. A swap applies the removal and reports the addition as needing a restart, so it can leave no admin in force until the restart. The server logs a warning when that happens.
  • In a team, only the node that leads grant writes revokes the grant. Another node reports the removal as partly applied. The leading node applies it when it reloads, and a follower applies it when it takes the lead.
  • The revoked grant ends the removed admin's authority on every instance. Another instance keeps admitting them on its own closed allowed-users list until it reloads.

Reading the reload report

swamp serve reload --server <url> --json prints the server's report. The settings block lists what the serve.yaml edit changed:

{
  "success": true,
  "reloadedCount": 12,
  "triggerOverridesChanged": 1,
  "settings": {
    "applied": ["max-concurrent-runs", "auth.admins", "schedule"],
    "needsRestart": [
      {
        "setting": "auth.admins",
        "reason": "adding an admin needs a restart; serve writes new admin grants only at startup"
      },
      {
        "setting": "port",
        "reason": "restart serve to change it; it needs a new process: the listener is bound to it"
      }
    ],
    "overridden": [
      { "setting": "max-run-duration", "by": "--max-run-duration" }
    ]
  },
  "errors": []
}
Field Meaning
settings.applied Settings in force now, named as serve.yaml names them
settings.needsRestart Settings left as they were, each with the reason and what to do
settings.overridden Settings a startup flag or environment variable (by) keeps pinned
configRejected true when serve.yaml failed startup's checks and nothing in it applied
warnings Changes the reload left unapplied, such as a webhooks list ignored for --webhook flags
errors What failed
reloadedCount Extension types reloaded
triggerOverridesChanged Trigger overrides changed from serve.yaml
webhooksReloaded Webhook route changes applied
auditSinks Audit sinks in force after the reload

A setting listed under both applied and needsRestart, like auth.admins above, was partly applied. Without --json, the same report prints as an Applied: line and one warning per setting that needs a restart or is overridden. A local SIGHUP reload writes the same lines to the server log.

Each reload writes a serve.config.reloaded audit event naming the caller and the changed settings by group, never a value. When a setting that applies after the reload fails, such as a grant source reconcile, it moves to needs restart, a second serve.config.reloaded event with outcome failure names it, and the next reload tries it again. See Serve audit actions.

Extensions and the trust list

On reload, the server also:

  1. Re-reads all pulled extension bundles from .swamp/pulled-extensions/ and .swamp/bundles/. A bundle whose source changed loads as a new module; in-flight runs keep the old one.
  2. Re-reads .swamp.yaml and refreshes the auto-resolver's trusted collectives list.

All extension types (behaviors, reports, workflows, vaults) are reloaded. There is no per-extension targeting — a reload refreshes everything. Edited repository-local behaviors need no reload: serve checks them before every run.

Webhook routes

The webhooks list is validated as at startup. An entry is refused when it is null or not a mapping, its route does not start with /, its scheme is unknown, or it uses the generic scheme without a header. A refusal keeps the previous routes and is reported as a reload error:

Failed to reload webhook config: Invalid webhook at index 0 in /path/to/repo/.swamp/serve.yaml: route must start with '/', got 'hooks/bad'

A reload can add the first webhook route to a server that started with none. Route changes apply on the next request; in-flight runs finish against the route they matched.

Routes registered with --webhook flags are fixed until restart. When the server was started with --webhook and the config also lists webhooks, the reload ignores the list and warns:

Ignored the webhooks list in the serve config: routes come from --webhook flags, which are fixed at startup. Move them to webhooks in the serve config to change them with 'swamp serve reload', or restart serve.

Route files are re-read in either mode. See Route files — Loading for how a reload treats a refused or edited route file.

Trigger overrides

Trigger overrides define or change scheduled execution for workflows without editing the workflow YAML. There are two ways to update trigger overrides on a running server:

Direct update (no reload required)

swamp workflow trigger set and swamp workflow trigger remove with --server apply overrides directly to the running scheduler over WebSocket. The override is written to serve.yaml and the scheduler is updated immediately, with no reload.

With --server, swamp workflow trigger set --catch-up (any policy, including none) first checks that the server reports the schedule-catch-up capability. A server without it is refused before anything is saved:

The server (swamp <version>) does not support --catch-up, so it would save the override without its catch-up. Upgrade swamp serve, or run without --server.
# Set a trigger override on a remote server
swamp workflow trigger set nightly-report --schedule "0 3 * * *" \
  --server wss://swamp.acme.internal:9090

# Remove a trigger override on a remote server
swamp workflow trigger remove nightly-report \
  --server wss://swamp.acme.internal:9090

Full reload

swamp serve reload re-reads all trigger overrides from serve.yaml. Use this when overrides have been edited in serve.yaml directly rather than through the CLI.

See the Workflows reference for the full trigger set, trigger get, and trigger remove flag tables.

The --hot-reload flag

--hot-reload

Default: off. No reload needs it: --server reloads every server, and SIGHUP reloads every server not attached to a terminal. With it, the server also:

  • reloads on SIGHUP when it runs in a terminal;
  • stops at startup if it cannot write the PID files, instead of warning;
  • reloads its extensions after its own extension installs and removals. This reload does not re-read serve.yaml, so unrelated pending edits there wait for the next full reload.

Managed config

On a server whose datastore manages config, the config poller refreshes definitions every --datastore-poll-interval (default 30 s) and reloads the extension type registries when the config-tier lockfile changes. That reload re-reads triggers, webhooks and settings as well.

Platform availability

SIGHUP is a POSIX signal, so the local reload works on macOS and Linux. --hot-reload is refused on Windows; reload there with --server.