refactor: short windows service argument and clarify commands output
Diff
src/bin/server.rs | 2 +-
src/settings/cli.rs | 4 ++--
src/settings/mod.rs | 4 ++--
src/winservice.rs | 11 ++++++-----
4 files changed, 11 insertions(+), 10 deletions(-)
@@ -26,7 +26,7 @@ fn main() -> Result {
return winservice::uninstall_service();
}
}
} else if opts.general.as_windows_service {
} else if opts.general.windows_service {
return winservice::run_server_as_service();
}
}
@@ -179,10 +179,10 @@ pub struct General {
short = "s",
parse(try_from_str),
default_value = "false",
env = "SERVER_AS_WINDOWS_SERVICE"
env = "SERVER_WINDOWS_SERVICE"
)]
pub as_windows_service: bool,
pub windows_service: bool,
#[cfg(windows)]
@@ -207,10 +207,10 @@ impl Settings {
grace_period,
page_fallback,
#[cfg(windows)]
as_windows_service: opts.as_windows_service,
windows_service: opts.windows_service,
#[cfg(windows)]
commands: opts.commands,
},
@@ -185,7 +185,7 @@ pub fn install_service(config_file: Option<PathBuf>) -> Result {
let service_binary_path = std::env::current_exe().unwrap().with_file_name(SERVICE_EXE);
let mut service_binary_arguments = vec![OsString::from("--as-windows-service=true")];
let mut service_binary_arguments = vec![OsString::from("--windows-service=true")];
if let Some(f) = config_file {
@@ -216,6 +216,10 @@ pub fn install_service(config_file: Option<PathBuf>) -> Result {
"Windows Service ({}) is installed successfully!",
SERVICE_NAME
);
println!(
"Start the service typing: sc.exe start \"{}\" (it requires administrator privileges) or using the 'services.msc' application.",
SERVICE_NAME
);
Ok(())
}
@@ -237,10 +241,7 @@ pub fn uninstall_service() -> Result {
service.delete()?;
println!(
"Windows Service ({}) uninstalled successfully!",
SERVICE_NAME
);
println!("Windows Service ({}) is uninstalled!", SERVICE_NAME);
Ok(())
}