English|中文
rustfs-manager
is a Windows service management tool developed in Rust, built on top of the win-service-rs
library,
designed to provide functionality similar to Linux’s systemctl
. It manages the lifecycle of rustfs.exe
or similar
services, supporting operations such as installation, starting, stopping, status querying, and uninstallation.
win-service-rs
is a standalone Rust crate that encapsulates the Windows Service Control Manager (SCM) APIs, offering a
safe and user-friendly interface for any Windows service management needs.
This project leverages Rust’s memory safety and the robust capabilities of windows-rs
to deliver an efficient and
reliable service management solution. Whether for enterprise applications or automation scripts, rustfs-manager
and
win-service-rs
provide flexible support.
tracing
to output JSON-formatted logs, facilitating integration with ELK or Graylog.tokio
for high-concurrency scenarios.windows-rs
safe bindings, ensuring memory safety and reliable operations.rustup update stable
git clone https://github.com/houseme/win-service-rs.git
cd win-service-rs/examples/rustfs_manager
Cargo.toml
. Build the project with:
cargo build --release
config/config.toml
to update parameters like exe_path
, ensuring the rustfs.exe
path is valid.rustfs-manager
provides a command-line interface (CLI) with the following commands:
cargo run -- install
Registers rustfs.exe
as a Windows service.
cargo run -- start
cargo run -- stop
cargo run -- status
cargo run -- uninstall
Run cargo run -- --help
to see the full list of commands.
cargo build --release
Copy Files:
Copy target/release/rustfs-manager.exe
and config/config.toml
to the target server.
.\scripts\deploy.ps1
sc query RustFSManager
win-service-rs
is a standalone Rust crate that encapsulates Windows SCM APIs, providing a safe and user-friendly
interface for service management. Here’s how to use it:
Cargo.toml
:
[dependencies]
win-service-rs = { version = "0.1.0", features = ["async"] }
use win_service_rs::{ServiceConfig, ServiceManager, StartType};
#[tokio::main]
async fn main() -> Result<(), win_service_rs::Error> {
let mut manager = ServiceManager::new("RustFS")?;
let config = ServiceConfig::new(
"C:\\path\\to\\rustfs.exe".to_string(),
"RustFS Service".to_string(),
)
.with_description("RustFS File System Service".to_string())
.with_start_type(StartType::Demand);
manager.install(&config)?;
manager.async_start().await?;
let status = manager.async_status().await?;
println!("Service status: {:?}", status);
manager.async_stop().await?;
manager.uninstall()?;
Ok(())
}
Asynchronous Support:
With the async
feature enabled, use async_start
, async_stop
, and async_status
methods for high-concurrency
scenarios.
Error
type to handle SCM errors (e.g., access denied, service not found).rustfs-manager
or win-service-rs
requires administrator privileges.tracing
JSON logs to files for integration with ELK or Graylog.rustfs.exe
and rustfs-manager
to prevent unauthorized access.win-service-rs
with features like log monitoring or health checks.This project is licensed under the MIT ,Apache License. See the LICENSE-APACHE
,LICENSE-MIT
file for details.