Skip to main content

single_instance_check

Function single_instance_check 

Source
pub async fn single_instance_check(socket: &Path) -> StartupAction
Expand description

Perform the single-instance check at daemon startup.

Why: launchd respawns any non-zero exit, so a second instance that fails to bind causes an endless respawn storm. Exiting 0 when another healthy instance is detected short-circuits it.

What: a bare connect to socket. It deliberately does NOT call memory.health: the question is whether the endpoint is live, and a daemon that is up but degraded must not be reported absent and spawned on top of itself. An absent or dead socket returns StartupAction::Proceed, so a cold start is never blocked.

Test: single_instance_check_proceeds_when_nothing_is_serving, single_instance_check_exits_when_something_is_serving.