Skip to main content

Module daemon_lock

Module daemon_lock 

Source
Expand description

One daemon per config directory.

run holds <config dir>/daemon.lock exclusively for its whole life; the OS releases it when the process exits, however it exits. The tray UI uses is_held to tell “no daemon” (start one) from “a daemon is starting” (wait).

Structs§

DaemonLock
The held daemon lock; dropping it releases the lock.

Enums§

Acquired
The outcome of acquire.

Constants§

ACQUIRE_ATTEMPTS
How often acquire tries before concluding another daemon runs, and the pause between tries. Covers the instant the tray UI’s is_held probe holds the lock shared.
ACQUIRE_PAUSE
LOCK_FILE_NAME
The lock file’s name, next to config.toml.
PID_FILE_NAME
Where the daemon writes its pid, next to the lock. Separate from the lock file because Windows locks are mandatory: a locked file cannot be read, even by the process that holds it through another handle.
WAIT_POLL
How often a waiting daemon retries the lock. Safe range 0.5..=10 s.

Functions§

acquire
Take the daemon lock for the config at config_path, logging the outcome.
acquire_with
acquire with an explicit retry budget.
is_held
Whether a daemon holds the lock for the config at config_path.
lock_path_for
The lock file for the config at config_path.
pid_path_for
The pid file for the config at config_path.
wait_until_acquired
Block until this process holds the daemon lock (run --wait-for-lock, for a supervised daemon). Logs once when it starts waiting.