pub struct ServerManager { /* private fields */ }
Expand description
Main structure for managing server processes.
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 fn set_pid_file<P: ToString>(&mut self, pid_file: P) -> &mut Self
pub fn set_pid_file<P: ToString>(&mut self, pid_file: P) -> &mut Self
Sets the path to the PID file.
§Arguments
pid_file
- A string or any type that can be converted to a string representing the PID file path.
Sourcepub fn set_start_hook<F, Fut>(&mut self, func: F) -> &mut Self
pub fn set_start_hook<F, Fut>(&mut self, func: F) -> &mut Self
Sets the asynchronous function to be called before the server starts.
§Arguments
F
- An asynchronous function or closure to be executed.
Sourcepub fn set_server_hook<F, Fut>(&mut self, func: F) -> &mut Self
pub fn set_server_hook<F, Fut>(&mut self, func: F) -> &mut Self
Sets the main server function to be executed.
§Arguments
F
- The primary asynchronous function or closure for the server’s logic.
Sourcepub fn set_stop_hook<F, Fut>(&mut self, func: F) -> &mut Self
pub fn set_stop_hook<F, Fut>(&mut self, func: F) -> &mut Self
Sets the asynchronous function to be called before the server stops.
§Arguments
F
- An asynchronous function or closure to be executed for cleanup.
Sourcepub fn get_pid_file(&self) -> &str
pub fn get_pid_file(&self) -> &str
Gets the configured PID file path.
Sourcepub fn get_start_hook(&self) -> &ServerManagerHook
pub fn get_start_hook(&self) -> &ServerManagerHook
Gets a reference to the start hook.
Sourcepub fn get_server_hook(&self) -> &ServerManagerHook
pub fn get_server_hook(&self) -> &ServerManagerHook
Gets a reference to the server hook.
Sourcepub fn get_stop_hook(&self) -> &ServerManagerHook
pub fn get_stop_hook(&self) -> &ServerManagerHook
Gets a reference to the stop hook.
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.
Sourcepub async fn watch_detached(&self, run_args: &[&str]) -> ServerManagerResult
pub async fn watch_detached(&self, run_args: &[&str]) -> ServerManagerResult
Sourcepub async fn watch(&self, run_args: &[&str]) -> ServerManagerResult
pub async fn watch(&self, run_args: &[&str]) -> ServerManagerResult
Trait Implementations§
Source§impl Clone for ServerManager
impl Clone for ServerManager
Source§fn clone(&self) -> ServerManager
fn clone(&self) -> ServerManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more