pub struct ServerManager {
pub pid_file: String,
pub stop_hook: ServerManagerHook,
pub start_hook: ServerManagerHook,
pub server_hook: ServerManagerHook,
}Expand description
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.
Fields§
§pid_file: StringPath to the PID file for process tracking.
stop_hook: ServerManagerHookAn asynchronous function to be called before stopping the server.
start_hook: ServerManagerHookAn asynchronous function to be called before starting the server.
server_hook: ServerManagerHookServer function to be executed.
Implementations§
Source§impl ServerManager
Implementation of server management operations.
impl ServerManager
Implementation of server management operations.
Provides methods for starting, stopping and managing server processes.
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ServerManager instance.
This is a convenience method that calls ServerManager::default().
Sourcepub async fn start(&self)
pub async fn start(&self)
Starts the server in foreground mode.
Writes the current process ID to the PID file and executes the server function.
Sourcepub async fn stop(&self) -> ServerManagerResult
pub async fn stop(&self) -> ServerManagerResult
Stops the running server process.
Reads PID from file and terminates the process.
§Returns
ServerManagerResult- Operation result.
Sourcepub async fn start_daemon(&self) -> ServerManagerResult
pub async fn start_daemon(&self) -> ServerManagerResult
Starts the server in daemon (background) mode on Unix platforms.
§Returns
ServerManagerResult- Operation result.