pub struct DaemonManager {
PidFilePath: PathBuf,
IsRunning: Arc<RwLock<bool>>,
PlatformInfo: PlatformInfo,
PidLock: Arc<Mutex<()>>,
PidChecksum: Arc<Mutex<Option<String>>>,
ShutdownRequested: Arc<RwLock<bool>>,
}Expand description
Daemon lifecycle manager
Fields§
§PidFilePath: PathBufPID file path
IsRunning: Arc<RwLock<bool>>Whether daemon is running
PlatformInfo: PlatformInfoPlatform-specific daemon info
PidLock: Arc<Mutex<()>>Lock for atomic PID file operations (prevents race conditions)
PidChecksum: Arc<Mutex<Option<String>>>Checksum for PID file integrity verification
ShutdownRequested: Arc<RwLock<bool>>Graceful shutdown flag
Implementations§
Source§impl DaemonManager
impl DaemonManager
Sourcefn DefaultPidFilePath() -> PathBuf
fn DefaultPidFilePath() -> PathBuf
Get default PID file path based on platform
Sourcefn DetectPlatform() -> Platform
fn DetectPlatform() -> Platform
Detect current platform
Sourcefn DetectPlatformInfo() -> PlatformInfo
fn DetectPlatformInfo() -> PlatformInfo
Detect platform-specific information
Sourcepub async fn AcquireLock(&self) -> Result<()>
pub async fn AcquireLock(&self) -> Result<()>
Acquire daemon lock to ensure single instance This method provides comprehensive defensive coding with:
- Race condition protection through mutex locking
- PID file checksum verification
- Process validation checks
- Atomic operations with rollback on failure
- Timeout handling
Sourcepub async fn IsAlreadyRunning(&self) -> Result<bool>
pub async fn IsAlreadyRunning(&self) -> Result<bool>
Check if daemon is already running Performs comprehensive validation including:
- PID file existence check
- Checksum verification
- Process existence validation
- Stale PID file cleanup
Sourcefn ValidateProcess(pid: u32) -> bool
fn ValidateProcess(pid: u32) -> bool
Validate that a process with the given PID is running Performs thorough process validation and existence checks
Sourceasync fn CleanupStalePidFile(&self) -> Result<()>
async fn CleanupStalePidFile(&self) -> Result<()>
Cleanup stale PID file with validation and error handling
Sourcepub async fn ReleaseLock(&self) -> Result<()>
pub async fn ReleaseLock(&self) -> Result<()>
Release daemon lock with proper cleanup and rollback Ensures all resources are properly cleaned up even on failure
Sourcepub async fn RequestShutdown(&self) -> Result<()>
pub async fn RequestShutdown(&self) -> Result<()>
Request graceful shutdown
Sourcepub async fn ClearShutdownRequest(&self) -> Result<()>
pub async fn ClearShutdownRequest(&self) -> Result<()>
Clear shutdown request (for restart scenarios)
Sourcepub async fn IsShutdownRequested(&self) -> bool
pub async fn IsShutdownRequested(&self) -> bool
Check if shutdown has been requested
Sourcepub async fn GetStatus(&self) -> Result<DaemonStatus>
pub async fn GetStatus(&self) -> Result<DaemonStatus>
Get daemon status with comprehensive health information
Sourcepub fn GenerateServiceFile(&self) -> Result<String>
pub fn GenerateServiceFile(&self) -> Result<String>
Generate system service file for installation
Sourcefn GenerateSystemdService(&self) -> Result<String>
fn GenerateSystemdService(&self) -> Result<String>
Generate systemd service file with comprehensive configuration
Sourcefn GenerateLaunchdService(&self) -> Result<String>
fn GenerateLaunchdService(&self) -> Result<String>
Generate launchd service file with comprehensive configuration
Sourcefn GenerateWindowsService(&self) -> Result<String>
fn GenerateWindowsService(&self) -> Result<String>
Generate Windows service configuration file TODO: Integrate with winsvc crate for actual Windows Service registration
Sourcepub async fn InstallService(&self) -> Result<()>
pub async fn InstallService(&self) -> Result<()>
Install daemon as system service with validation
Sourceasync fn InstallSystemdService(&self) -> Result<()>
async fn InstallSystemdService(&self) -> Result<()>
Install systemd service with validation
Sourceasync fn InstallLaunchdService(&self) -> Result<()>
async fn InstallLaunchdService(&self) -> Result<()>
Install launchd service with validation
Sourceasync fn InstallWindowsService(&self) -> Result<()>
async fn InstallWindowsService(&self) -> Result<()>
Install Windows service TODO: Integrate with winsvc crate for actual service registration
Sourcepub async fn UninstallService(&self) -> Result<()>
pub async fn UninstallService(&self) -> Result<()>
Uninstall system service with proper coordination
Sourceasync fn UninstallSystemdService(&self) -> Result<()>
async fn UninstallSystemdService(&self) -> Result<()>
Uninstall systemd service with proper coordination
Sourceasync fn UninstallLaunchdService(&self) -> Result<()>
async fn UninstallLaunchdService(&self) -> Result<()>
Uninstall launchd service with proper coordination
Sourceasync fn UninstallWindowsService(&self) -> Result<()>
async fn UninstallWindowsService(&self) -> Result<()>
Uninstall Windows service
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DaemonManager
impl !RefUnwindSafe for DaemonManager
impl Send for DaemonManager
impl Sync for DaemonManager
impl Unpin for DaemonManager
impl !UnwindSafe for DaemonManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].