Skip to main content

Module instance_lock

Module instance_lock 

Source
Expand description

#405 — single-instance lock per node_id.

Two iicp-node serve processes for the SAME node_id fight: each registration rotates the directory-issued token and invalidates the other’s, so they enter a 401 → re-register war that makes the node flap in the directory. This guard prevents that by holding a pidfile at ~/.iicp/run/<node_id>.pid; a second live process for the same node_id is refused (unless --force). Distinct node_ids are unaffected — a fleet of N nodes runs fine (each has its own lock).

Fail-open: any filesystem error degrades to a no-op lock (with a warning) — the guard must never prevent a node from starting.

Structs§

InstanceLock
Held for the lifetime of serve; removes the pidfile on drop.