Expand description
Hot configuration reload.
Re-reads rws.config.toml without restarting the server. Non-binding
settings — those that would require a new TCP socket (IP, port,
thread count) or a different default TLS cert/key path — are logged as
ignored. All other settings take effect on the next incoming request.
On TLS builds a SIGHUP also rebuilds the TLS acceptor, so renewed
certificate files and changed [[virtual_host]] entries are picked up.
§Triggering a reload
- Unix signal: send
SIGHUPto the server process.kill -HUP $(pidof rws) - HTTP endpoint:
POST /admin/config/reload(no body required).
§What is hot-reloadable
| Setting | Env var |
|---|---|
| CORS — all fields | RWS_CONFIG_CORS_* |
| Rate-limit thresholds | RWS_CONFIG_RATE_LIMIT_MAX_REQUESTS, RWS_CONFIG_RATE_LIMIT_WINDOW_SECS |
| Log format | RWS_CONFIG_LOG_FORMAT |
| Request allocation size | RWS_CONFIG_REQUEST_ALLOCATION_SIZE_IN_BYTES |
| Max body size | RWS_CONFIG_MAX_BODY_SIZE_IN_BYTES |
Tera templates (tera feature, if template::init() was called) | re-read from disk — see [crate::template] |
Proxy [[route]], [[upstream]], [middleware] (config-driven proxy) | validated, then swapped in; a file with errors leaves the running routes in place — see crate::proxy_config::ConfigDrivenApp::reload_from_str |
Anything registered with on_reload | your hook |
§What is NOT hot-reloadable (requires restart)
| Setting | Why |
|---|---|
| IP / Port | Bound socket cannot be moved |
| Thread count | Thread pool is fixed at startup |
| Default TLS cert / key path | run_tls keeps the startup paths (the files themselves are re-read on SIGHUP) |
[[tcp_proxy]] / [[udp_proxy]] / [[ws_proxy]] | Bound listener sockets |
Structs§
- Config
Snapshot - Snapshot of all hot-reloadable configuration values at a point in time.
Statics§
- RELOAD_
REQUESTED - Global flag set by the SIGHUP signal handler.
Functions§
- current
- Returns a clone of the current hot-reloadable configuration snapshot.
- install_
sighup_ handler - Install a
SIGHUPsignal handler that setsRELOAD_REQUESTED. - last_
reload - How many
reloads have completed, and the errors the last one’s hooks reported withreport_error(empty: it applied cleanly). For the admin API, which requests a reload and waits for the count to move. - on_
reload - Run
hookat the end of everyreload, after the settings have been re-read — for state that is built from the configuration file rather than read fromRWS_CONFIG_*per request. The config-driven proxy registers one to reload its routes (crate::proxy_config::ConfigDrivenApp::reload_from_file). - reload
- Re-read
rws.config.tomland apply all hot-reloadable changes in-place. - report_
error - A reload hook couldn’t apply its part (the old state stays): recorded for
last_reloaduntil the next reload. - request_
reload - Ask the running server to reload, exactly as
SIGHUPdoes: on Unix it raisesSIGHUPfor this process, so the server’s own handler reloads the config, the proxy routes and (TLS builds) the certificates; elsewhere it callsreload. SettingRELOAD_REQUESTEDalone only reaches the HTTP/1.1-only server’s accept loop — the async servers never read it, so the MCPreload_configtool did nothing in them.