Repository navigation
Description
Companion to #367 (SIGHUP hot-reload).
Why
#367 wired SIGHUP to call RuntimeReloadState::reload() for the two reloadable fields (payment.rate_per_mb, observability.log_level). Two real wins from also exposing this on the admin HTTP surface:
- Structured response. SIGHUP is fire-and-forget — operators have to inspect logs to learn whether the reload applied or which fields changed. An RPC method can return
{ status: "reloaded", ... }or{ status: "error", reason: ... }directly. - Non-Unix-y orchestrators. systemd users keep using
ExecReload=to send SIGHUP. Windows hosts, some PaaS, container orchestrators, and operator scripts that don't speak signals get a programmatic path.
Fits the existing local-admin-http appendix pattern exactly — admin_v1_health and admin_v1_peersList already expose health + peer-table reads on the same loopback surface; reload joins as the third operator-local control action.
Shape
New jsonrpsee method on the existing admin_v1 namespace:
#[method(name = "reload")]
async fn reload(&self) -> RpcResult<ReloadResponse>;
pub struct ReloadResponse {
pub status: ReloadStatus, // Reloaded | Noop | Error
pub rate_per_mb: u64, // current value after reload
pub log_level: String, // current value after reload
pub error: Option<String>, // present iff status == Error
}Both SIGHUP and admin_v1_reload call the same RuntimeReloadState::reload() — the existing mutex inside that function already serialises concurrent reloads, so racing paths just queue.
CLI ride-along: decdn node reload [--config <path>] calls the RPC and prints the response (matching the decdn node health / decdn node peers pattern).
Edge cases
- No config path in use. SIGHUP today logs
"SIGHUP received but no config file path is in use; ignoring". The RPC method returns{ status: "error", reason: "no config path in use" }(HTTP 200 with a structured body — not a transport-level error). - Reload fails (parse / validation / mutex poison). RPC returns the same structured error response. The existing reload contract preserves previous values on error; that contract is unchanged.
- Concurrent SIGHUP + RPC. Serialised by the mutex inside
RuntimeReloadState::reload()— both calls succeed; the second one is a noop diff if nothing changed between them.
Files
| File | Change |
|---|---|
crates/node/src/admin.rs |
New ReloadResponse + ReloadStatus types; add reload to AdminRpc trait; impl in AdminRpcImpl |
crates/node/src/admin.rs (AdminState) |
Carry Arc<RuntimeReloadState> and Option<PathBuf> config path |
crates/node/src/runtime/mod.rs |
Pass the new state into AdminState::new |
crates/node/src/commands/node.rs |
New reload CLI subcommand |
crates/node/src/cli/node.rs |
Surface the new subcommand |
| Tests | Roundtrip; success/error/noop variants; concurrent-with-SIGHUP serialisation |
Acceptance
-
admin_v1_reloadreturns a structuredReloadResponseon the loopback admin port. -
decdn node reloadexits 0 on success, non-zero on error, prints the response. - SIGHUP and the RPC share
RuntimeReloadState::reload(); both can be exercised concurrently without races (test). - No config-path → structured error response, not a panic.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
feat(node): add admin_v1_reload alongside SIGHUP hot-reload (#373) (#381