server-manager 10.3.0

server-manager is a rust library for managing server processes. It encapsulates service startup, shutdown, and background daemon mode. Users can specify the PID file, log file paths, and other configurations through custom settings, while also passing in their own asynchronous server function for execution. The library supports both synchronous and asynchronous operations. On Unix and Windows platforms, it enables background daemon processes.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::*;

/// Main structure for managing server processes.
///
/// Accessors are generated by `#[derive(Data)]`. The setters take owned `String` /
/// `ServerManagerHook` values, so call sites convert `&str` and closures themselves.
#[derive(Clone, Data)]
pub struct ServerManager {
    /// Path to the PID file for process tracking.
    pub pid_file: String,
    /// An asynchronous function to be called before stopping the server.
    pub stop_hook: ServerManagerHook,
    /// An asynchronous function to be called before starting the server.
    pub start_hook: ServerManagerHook,
    /// Server function to be executed.
    pub server_hook: ServerManagerHook,
}