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() -> ServerManager
pub fn new() -> ServerManager
Creates a new ServerManager
instance.
This is a convenience method that calls ServerManager::default()
.
Sourcepub fn set_pid_file<P>(&mut self, pid_file: P) -> &mut ServerManagerwhere
P: ToString,
pub fn set_pid_file<P>(&mut self, pid_file: P) -> &mut ServerManagerwhere
P: ToString,
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 ServerManager
pub fn set_start_hook<F, Fut>(&mut self, func: F) -> &mut ServerManager
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 ServerManager
pub fn set_server_hook<F, Fut>(&mut self, func: F) -> &mut ServerManager
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 ServerManager
pub fn set_stop_hook<F, Fut>(&mut self, func: F) -> &mut ServerManager
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,
) -> &Arc<dyn Fn() -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>
pub fn get_start_hook( &self, ) -> &Arc<dyn Fn() -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>
Gets a reference to the start hook.
Sourcepub fn get_server_hook(
&self,
) -> &Arc<dyn Fn() -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>
pub fn get_server_hook( &self, ) -> &Arc<dyn Fn() -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>
Gets a reference to the server hook.
Sourcepub fn get_stop_hook(
&self,
) -> &Arc<dyn Fn() -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>
pub fn get_stop_hook( &self, ) -> &Arc<dyn Fn() -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>
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) -> Result<(), Box<dyn Error>>
pub async fn stop(&self) -> Result<(), Box<dyn Error>>
Stops the running server process.
Reads PID from file and terminates the process.
§Returns
ServerManagerResult
- Operation result.
Sourcepub async fn start_daemon(&self) -> Result<(), Box<dyn Error>>
pub async fn start_daemon(&self) -> Result<(), Box<dyn Error>>
Starts the server in daemon (background) mode on Unix platforms.
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 moreSource§impl Default for ServerManager
Provides a default implementation for ServerManager
.
impl Default for ServerManager
Provides a default implementation for ServerManager
.
Source§fn default() -> ServerManager
fn default() -> ServerManager
Creates a default ServerManager
instance with empty hooks and no PID file configured.