reload_ipc
The protocol is intentionally trivial: any successful connect() is interpreted
as a “reload now” signal. No bytes are exchanged. The CLI side
(crate::cli::web_notify) opens and immediately drops a UnixStream to fire
the signal.
fn bind_reload_socket
pub fn bind_reload_socket(path: &Path) -> std::io::Result<UnixListener>Bind a unix domain socket listener at path, transparently recovering from a
stale socket file left behind by a previous process.
On EADDRINUSE the function probes the existing socket with a sync connect().
If something is actually listening the original error is returned (the caller
should not steal the socket from a live process). Otherwise the stale file is
unlinked and the bind is retried once.
| Parameter | Type | Description |
|---|---|---|
path |
&Path | where to create the socket file |
| returns | std::io::Result<UnixListener> | The bound listener, or the I/O error from binding, from removing the stale file, or the original EADDRINUSE error when another process is listening. |
fn spawn_reload_listener
pub fn spawn_reload_listener(listener: UnixListener, tx: Sender<()>) -> JoinHandle<()>Spawn an accept loop that fires a reload signal on every incoming connection.
The streams are dropped immediately — the bare connection itself is the entire
payload. The returned JoinHandle is detached by callers in production and
joined in tests; the runtime aborts the task when the server’s tokio runtime
shuts down.
Accept errors are logged as warnings and the loop goes on; it never ends by itself.
| Parameter | Type | Description |
|---|---|---|
listener |
UnixListener | the bound reload socket |
tx |
Sender<()> | the SSE reload channel that each connection sends one signal on |
| returns | JoinHandle<()> | The handle of the spawned accept loop. |
struct ReloadSocketGuard
pub struct ReloadSocketGuardDrop guard that removes the reload socket file when the web server exits cleanly.
Abrupt termination (SIGKILL, panic during runtime shutdown) may leave the file
behind; bind_reload_socket handles that case on the next startup.
| Field | Type | Description |
|---|---|---|
path |
PathBuf | The socket file to remove on drop. |
Implements Drop.
ReloadSocketGuard::new
pub fn new(path: PathBuf) -> SelfCreate a guard that will unlink path when dropped.
| Parameter | Type | Description |
|---|---|---|
path |
PathBuf | the socket file to remove; a missing file is ignored |
| returns | Self | The guard; keep it alive for as long as the socket should exist. |