This commit is contained in:
chao wan 2024-11-03 00:46:49 +08:00
parent 084f0deddd
commit bbbdc84aa9

View File

@ -162,17 +162,18 @@ pub struct Service{
impl Service { impl Service {
pub fn new() -> Result<Self, anyhow::Error> { pub fn new() -> Result<Self, anyhow::Error> {
let service_manager = if cfg!(windows) { #[cfg(target_os = "windows")]
Box::new( let service_manager = Box::new(
crate::arch::windows::WinServiceManager::new( crate::arch::windows::WinServiceManager::new(
Some(OsString::from("EasyTier Service")), Some(OsString::from("EasyTier Service")),
Some(OsString::from(env!("CARGO_PKG_DESCRIPTION"))), Some(OsString::from(env!("CARGO_PKG_DESCRIPTION"))),
vec![OsString::from("dnscache"), OsString::from("rpcss")], vec![OsString::from("dnscache"), OsString::from("rpcss")],
)? )?
) );
} else {
<dyn ServiceManager>::native()? #[cfg(not(target_os = "windows"))]
}; let service_manager = <dyn ServiceManager>::native()?;
Ok(Self { Ok(Self {
lable: env!("CARGO_PKG_NAME").parse().unwrap(), lable: env!("CARGO_PKG_NAME").parse().unwrap(),
service_manager service_manager