server-manager 0.1.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 platforms, it enables background daemon processes, while on non-Unix platforms, it returns an appropriate error message.
docs.rs failed to build server-manager-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: server-manager-5.0.3

server-manager

Official Documentation

Api Docs

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 platforms, it enables background daemon processes, while on non-Unix platforms, it returns an appropriate error message.

Installation

To use this crate, you can run cmd:

cargo add server-manager

Use

use server_manager::*;
use std::fs;
use std::time::Duration;
let pid_file: String = "test_pid.pid".to_string();
let _ = fs::remove_file(&pid_file);
let config: ServerConfig = ServerConfig {
    pid_file: pid_file.clone(),
    stdout_log: "test_stdout.log".to_string(),
    stderr_log: "test_stderr.log".to_string(),
};
let dummy_server = || async {
    tokio::time::sleep(Duration::from_secs(1)).await;
};
let manager = ServerManager::new(config, dummy_server);
let res: Result<(), Box<dyn Error>> = manager.start_daemon();
println!("start_daemon {:?}", res);
let res: Result<(), Box<dyn Error>> = manager.stop();
println!("stop {:?}", res);
manager.start().await;
let _ = fs::remove_file(&pid_file);

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Contact

For any inquiries, please reach out to the author at ltpp-universe root@ltpp.vip.