Skip to main content

Module daemon

Module daemon 

Source
Expand description

Daemon management functionality for the kasl watch command.

Provides comprehensive background process management for the kasl activity monitoring system including spawning, signal handling, and graceful shutdown.

§Features

  • Process Spawning: Creates detached background processes for continuous monitoring
  • Signal Handling: Responds to system signals for graceful shutdown and restart
  • PID Management: Tracks running processes and prevents duplicate instances
  • Cross-Platform Support: Handles platform differences between Unix and Windows
  • Resource Cleanup: Ensures proper cleanup of database connections and system resources
  • Error Recovery: Manages process failures and provides meaningful error messages

§Usage

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
Finds and stops the running daemon process.
run_with_signal_handling
Runs the daemon with proper signal handling for graceful shutdown.
spawn
Spawns the application as a detached background process.
stop