Skip to main content

Module daemon

Module daemon 

Source
Expand description

Background process management for kasl watch: spawn detached, track by PID file, stop, and the daemon’s own signal-handled entry point.

use kasl::libs::daemon;

daemon::spawn()?;                           // Start background monitoring
daemon::stop()?;                            // Stop background monitoring
daemon::run_with_signal_handling().await?;  // Run with signal handling

Functions§

is_running
True when the PID file exists, parses, and names a live process.
run_with_signal_handling
The daemon entry point: runs the monitor and the Jira inbox poller, shutting both down on SIGTERM/SIGINT (Ctrl+C on Windows) and removing the PID file on the way out.
spawn
Re-launches the current executable detached (--daemon-run), first stopping any daemon the PID file points at, and records the new PID. Detachment is setsid on Unix, CREATE_NO_WINDOW on Windows; a failed stop of the old daemon is a warning, not a blocker.
stop
Stops the daemon; “already stopped” counts as success, so cleanup scripts can call it unconditionally.