Expand description
Daemon lifecycle management: PID file, Unix domain socket, grace period, signal handling, and cleanup.
This module contains all the logic for the daemon’s lifecycle:
- PID file at
StorageLayout::daemon_pid_file()prevents duplicate instances and allows clients to detect a running daemon. - Unix domain socket at
StorageLayout::daemon_socket()accepts connections from MCP server proxies. - Grace period (5 minutes) triggers automatic shutdown when no clients are connected.
- Signal handling catches SIGTERM/SIGINT for clean shutdown.
Constants§
- GRACE_
PERIOD - Duration of the grace period before the daemon shuts down after the last client disconnects.
Functions§
- check_
existing_ daemon - Check whether an existing PID file points to a running process.
- cleanup
- Best-effort removal of the PID file and socket.
- run_
daemon - Run the daemon’s accept loop and grace-period shutdown logic.
- write_
pid_ file - Write the current process ID to the PID file.