Skip to main content

max / makenotwork

server: MNW_CHECK_CONFIG mode — validate config and exit, no side effects Loads Config::from_env() with the process environment and exits 0 (prints "MNW_CONFIG_CHECK: ok") or 1 (prints the error), with no DB connection, no migrations, and no socket bind. Backs Sando's opt-in pre-swap config-drift guard (run on the target with its env sourced, before the symlink swap) and is handy by hand for validating a node's env. The stable sentinel line lets a caller tell a genuine config error from a binary too old to know the mode. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-07-08 23:57 UTC
Commit: 692e0e87159400456d22fee38c0c08b374d4badf
Parent: 942b5bb
1 file changed, +22 insertions, -0 deletions
@@ -63,6 +63,28 @@ async fn main() {
63 63 return;
64 64 }
65 65
66 + // Config-only validation mode. Loads Config::from_env() with the process
67 + // environment and exits — no DB connection, no migrations, no socket bind —
68 + // so a required var missing on a target (e.g. CDN_BASE_URL) is caught
69 + // *before* a deploy swaps the `current` symlink and restarts into a crash
70 + // loop. Sando's pre-swap config-drift guard runs `MNW_CHECK_CONFIG=1
71 + // <binary>` on the target with its env sourced; also handy by hand. Prints a
72 + // stable sentinel line so a caller can distinguish a genuine config error
73 + // (exit 1) from a binary too old to support this mode (which would ignore
74 + // the var and fall through to normal startup).
75 + if std::env::var("MNW_CHECK_CONFIG").is_ok() {
76 + match Config::from_env() {
77 + Ok(_) => {
78 + println!("MNW_CONFIG_CHECK: ok");
79 + std::process::exit(0);
80 + }
81 + Err(e) => {
82 + eprintln!("MNW_CONFIG_CHECK: error: {e}");
83 + std::process::exit(1);
84 + }
85 + }
86 + }
87 +
66 88 let config = Config::from_env().expect("Failed to load configuration");
67 89 tracing::info!("Configuration loaded");
68 90