Skip to main content

Module registry

Module registry 

Source
Expand description

daemon.json / daemon.lock / daemon.pid under registry_dir() (PLAN-phase2 §2.11). The flock on daemon.lock is THE liveness oracle (jcode socket.rs:89-139): a daemon is alive iff someone holds the lock. A socket file with no lock holder is stale and gets unlinked. Nobody unlinks on ECONNREFUSED alone.

Re-exports§

pub use crate::events::registry::daemon_paths;
pub use crate::events::registry::daemon_paths_in;
pub use crate::events::registry::DaemonPaths;

Structs§

DaemonInfo
daemon.json — pid + profile + paths only. Never credentials.
DaemonLock
Held for the daemon’s lifetime; dropping releases the flock.
Metadata
The daemon’s daemon.json record as this image holds it, and the writes of it: the start write, Self::publish (reload, and the restore after a failed exec), Self::heal (Ping) and Self::cleanup (shutdown).
SpawnLock
Held while a client spawns the daemon; dropping releases it.

Enums§

Healed
What Metadata::heal did.

Constants§

JSON_HEAL_LOG_EVERY
At most one daemon.json rewritten line per this interval; heals in between are counted in the next line.

Functions§

heal_daemon_json
The lock holder puts its own daemon.json (and daemon.pid) back when the file is missing, unreadable, or names another pid: an older synaps that lists sessions unlinks every run-dir *.json it cannot parse as a session card. info is the record the daemon holds in memory; the write is write_daemon_json’s (tmp + rename, 0600). Anything at the path that is not a regular file (a symlink, a directory, a socket) is left alone, as [cleanup_metadata] does. Returns whether it wrote.
is_alive
Liveness probe: try to take the lock; success means nobody holds it (dead or never started) — release immediately. Never unlinks anything.
read_daemon_json
reap_stale
Unlink sock/json/pid if — and only if — no daemon holds the lock. Returns true when something stale was removed.
write_daemon_json
Write daemon.json + daemon.pid atomically (each through its own temp file + rename), 0600.
write_private_atomic
0600 temp file + rename (reload-state), as [write_atomic].