Skip to main content

Module daemon

Module daemon 

Source
Expand description

sqry daemon subcommand handlers.

Provides lifecycle management for the sqryd daemon from the sqry CLI:

  • sqry daemon start – resolve sqryd binary, exec sqryd start --detach.
  • sqry daemon stop – connect via [DaemonClient], send daemon/stop, poll socket gone.
  • sqry daemon status – connect via [DaemonClient], send daemon/status, render.
  • sqry daemon logs – tail / follow the daemon log file.

Additionally exposes try_auto_start_daemon for future Task 13 wiring into query commands via the SQRY_DAEMON_AUTO_START=1 opt-in environment variable.

§Tokio runtime

The stop and status subcommands need async I/O for [DaemonClient]. A current_thread runtime is created inside each handler — tokio is already a transitive dependency of sqry-cli via sqry-lsp.

§Platform notes

try_connect_sync uses std::os::unix::net::UnixStream on Unix and a named-pipe existence probe on Windows so callers can check reachability without spinning up a Tokio runtime.

Functions§

format_uptime
Format an uptime in seconds as "Xd Yh Zm" (or shorter when leading units are zero).
human_bytes
Format a byte count as a human-readable string (B / KB / MB / GB / TB).
run
Dispatch a sqry daemon subcommand.
tail_follow
Print the last initial_lines lines from path, then follow the file for new content using notify::RecommendedWatcher.
tail_last_n
Print the last n lines from path to stdout.
try_auto_start_daemon
Check whether the daemon auto-start opt-in is active, and if so, try to start the daemon.
try_connect_sync
Synchronously probe whether the daemon socket is reachable.