Skip to main content

Module daemon

Module daemon 

Source
Expand description

khived daemon server — persistent warm runtime over a Unix socket.

The daemon binds ~/.khive/khived.sock, accepts length-prefixed request frames, dispatches them through a DaemonDispatch implementor, and serves results back. It is transport-agnostic: the MCP crate provides the dispatch impl, but any future client (CLI, HTTP gateway) can reuse this server.

The client side (forwarding, auto-spawn) lives in the transport crate (e.g. khive-mcp), not here.

Structs§

DaemonRequestFrame
Request frame sent from a client to the daemon.
DaemonResponseFrame
Response frame sent from the daemon back to a client.

Constants§

MAX_FRAME_BYTES
Maximum frame size accepted in either direction.
PROTOCOL_VERSION
Wire protocol version for the daemon IPC framing.

Traits§

DaemonDispatch
Transport-agnostic dispatch interface for the daemon server.

Functions§

acquire_recovery_lock
Acquire an exclusive advisory flock on the recovery/startup lock file.
env_truthy
Returns true for non-empty env values that are not "0" or "false".
lock_path
Advisory lock file used to serialize stale-daemon recovery across concurrent clients (flock on the file; released when the lock file handle is dropped).
pid_path
PID file path written by the daemon.
read_frame
Read one length-prefixed frame (4-byte BE u32 length + JSON bytes).
run_daemon
Run the daemon: bind the socket, warm in the background, serve request frames until SIGTERM/SIGINT.
socket_path
Unix socket path the daemon binds and clients connect to.
write_frame
Write one length-prefixed frame.