Skip to main content

Module daemon_client

Module daemon_client 

Source
Expand description

Daemon client mode — connects to the infinity daemon over a unix socket (or in-memory channels) and bridges the protocol messages to the terminal.

Functions§

ensure_daemon_running
launch_daemon
Launch the daemon as a background process and wait until it prints its ready line on stdout. If the daemon exits first (e.g. a configuration error), the error includes everything it printed to stdout/stderr, which would otherwise be invisible for a detached process.
restart_daemon
Restart the daemon: stop the running instance (if any), then launch a fresh one.
run_client
Core client logic — works with channels regardless of transport, and any terminal implementation. Production wrappers pass the crossterm-backed terminal and the process cwd; tests substitute a virtual terminal, scripted events, and a temp cwd.
run_headless
Send a task to the daemon and exit without opening the TUI.
run_in_memory
Run in-memory mode — no serialization, direct channel passing.
run_with_daemon
Connect to the daemon over a unix socket (serialized framing).
running_daemon_pid
Returns the pid of the running daemon, or None if it is not running. Probes the pid recorded in the pid file with signal 0: only ESRCH (no such process) is treated as not running, so a stale pid file (e.g. left behind by a crash) is detected while an unsignalable-but-alive process (EPERM) is not misreported as stopped. Pid reuse is an accepted risk: the daemon removes its pid file on clean shutdown, and both the file and the daemon are per-user.
stop_daemon
Stop the running daemon: send SIGTERM and wait for the process to fully exit (so its shutdown cleanup of the socket and pid files completes). Returns Ok(Some(pid)) if a daemon was stopped, Ok(None) if no daemon is running.