Skip to content

feat: reload runtime configuration on SIGHUP - #17

Merged
iamd3vil merged 1 commit into
mainfrom
feat/config-reload
Sep 17, 2026
Merged

iamd3vil merged 1 commit into
mainfrom
feat/config-reload

Conversation

@iamd3vil

Copy link
Copy Markdown
Owner

Summary

Remove the need to restart Hedwig for common policy changes and key rotations. On Unix, send kill -HUP <hedwig-pid> to reread the configuration file supplied at startup.

  • Reload sender/recipient domain filters, auth credentials, log level, DKIM configuration, and TLS certificate/key files.
  • Prepare all replacements before publishing a shared runtime snapshot. Retain the active configuration on failure and reject changes to restart-only fields.
  • Preserve existing authenticated sessions and connection-level TLS state. New auth attempts, filter checks, signing operations, and connections use the updated settings.
  • Preserve valid HEDWIG_LOG_LEVEL overrides and register persistent signal streams so SIGINT during reload still initiates shutdown.
  • Report safe component/stage/listener diagnostics without logging credentials or key content. Exclude passwords from config serialization.

Configuration and compatibility

No configuration migration is required. Authentication enablement, listener addresses/count/TLS modes, storage settings, worker counts, and other startup-only fields still require a restart. DKIM may be enabled or disabled through reload. Key and certificate files are reread even when their paths are unchanged.

Verification

  • cargo test --workspace: 325 unit tests and one doc test passed.
  • cargo fmt --check: passed.
  • cargo clippy --workspace --all-targets: completed with nine pre-existing warnings in unchanged metrics/logqueue tests.
  • git diff --check: passed.
  • dev/verify-config-reload.py: passed against both log and filesystem storage using real SMTP delivery through the dev DNS and fake MTA.

End-to-end coverage includes PLAIN/LOGIN/CRAM-MD5 credential changes, sender/recipient filters, DKIM rotation and disable/re-enable, implicit TLS and STARTTLS certificate rotation, same-path certificate replacement, log-level changes, failed-reload rollback, secret redaction, and unchanged process PID.

The SIGINT regression was reproduced against the prior binary by blocking a reload on a key-file FIFO. The fixed binary shuts down gracefully after a single SIGINT during that same blocked reload on both storage backends.

Reload domain filters, authentication credentials, log level, DKIM signing, and TLS certificates without restarting listeners or delivery workers. Prepare replacements before publishing a shared runtime snapshot and reject restart-only changes without modifying active settings.

Retain existing authenticated and TLS sessions, preserve valid log environment overrides, and keep shutdown signals pending during reload. Report safe component-specific failures and omit passwords from config serialization.

Add rollback, policy-boundary, credential, and secret-redaction tests plus a Docker SMTP verifier covering both storage backends and SIGINT during blocked reload. Document reload behavior and limitations.

Validation: 325 unit tests and one doc test pass; formatting and diff checks pass; clippy reports only nine existing warnings. End-to-end SMTP verification passes for log and fs storage.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying hedwig with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1eca37b
Status: ✅  Deploy successful!
Preview URL: https://1e3eefcd.hedwig-1mq.pages.dev
Branch Preview URL: https://feat-config-reload.hedwig-1mq.pages.dev

View logs

@iamd3vil
iamd3vil merged commit 5832069 into main Sep 17, 2026
2 checks passed
@iamd3vil
iamd3vil deleted the feat/config-reload branch September 17, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant