diff --git a/src/core/nal.rs b/src/core/nal.rs index 43c31ac..f7f972f 100644 --- a/src/core/nal.rs +++ b/src/core/nal.rs @@ -93,6 +93,7 @@ pub fn init_config() -> NalConfig { pub fn get_no_proxy_client() -> Client { Client::builder() .no_proxy() // 禁用代理 + .connect_timeout(Duration::from_secs(10)) .timeout(Duration::from_secs(30)) .build().unwrap() } diff --git a/src/main.rs b/src/main.rs index 5e3a631..8bfeaab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,6 +33,7 @@ async fn main() { return; } if cli.uninstall { + service.stop(); service.uninstall(); return; } diff --git a/src/util/cmd.rs b/src/util/cmd.rs index da23b45..a7c0956 100644 --- a/src/util/cmd.rs +++ b/src/util/cmd.rs @@ -3,10 +3,10 @@ use clap_derive::Parser; #[derive(Parser)] #[command(version, about, long_about = None)] pub struct Cli { - #[arg(short = 'i')] + #[arg(short = 'i', long)] pub install: bool, - #[arg(short,long)] + #[arg(short, long)] pub uninstall: bool, #[arg(long)] @@ -15,6 +15,6 @@ pub struct Cli { #[arg(long)] pub stop: bool, - #[arg(short,long)] - pub run: bool + #[arg(short, long)] + pub run: bool, } diff --git a/src/util/service.rs b/src/util/service.rs index cb2a790..c92e155 100644 --- a/src/util/service.rs +++ b/src/util/service.rs @@ -1,4 +1,5 @@ use std::env; +use std::ffi::OsString; use std::path::PathBuf; use log::{debug, info}; use service_manager::{ServiceInstallCtx, ServiceLabel, ServiceManager, ServiceStartCtx, ServiceStopCtx, ServiceUninstallCtx}; @@ -40,7 +41,7 @@ impl Service { self.service_manage.install(ServiceInstallCtx { label: self.name.clone(), program: self.path.clone(), - args: vec![], + args: vec![OsString::from("--run")], contents: None, // 特定于系统的服务内容的可选字符串。 username: None, // 可选字符串,供备用用户运行服务。 working_directory: None, // 服务进程的工作目录的可选字符串。