Skip to main content

Module config_reload

Module config_reload 

Source
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 SIGHUP to the server process.
    kill -HUP $(pidof rws)
  • HTTP endpoint: POST /admin/config/reload (no body required).

§What is hot-reloadable

SettingEnv var
CORS — all fieldsRWS_CONFIG_CORS_*
Rate-limit thresholdsRWS_CONFIG_RATE_LIMIT_MAX_REQUESTS, RWS_CONFIG_RATE_LIMIT_WINDOW_SECS
Log formatRWS_CONFIG_LOG_FORMAT
Request allocation sizeRWS_CONFIG_REQUEST_ALLOCATION_SIZE_IN_BYTES
Max body sizeRWS_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_reloadyour hook

§What is NOT hot-reloadable (requires restart)

SettingWhy
IP / PortBound socket cannot be moved
Thread countThread pool is fixed at startup
Default TLS cert / key pathrun_tls keeps the startup paths (the files themselves are re-read on SIGHUP)
[[tcp_proxy]] / [[udp_proxy]] / [[ws_proxy]]Bound listener sockets

Structs§

ConfigSnapshot
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 SIGHUP signal handler that sets RELOAD_REQUESTED.
on_reload
Run hook at the end of every reload, after the settings have been re-read — for state that is built from the configuration file rather than read from RWS_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.toml and apply all hot-reloadable changes in-place.
request_reload
Ask the running server to reload, exactly as SIGHUP does: on Unix it raises SIGHUP for this process, so the server’s own handler reloads the config, the proxy routes and (TLS builds) the certificates; elsewhere it calls reload. Setting RELOAD_REQUESTED alone only reaches the HTTP/1.1-only server’s accept loop — the async servers never read it, so the MCP reload_config tool did nothing in them.