chore(rustdesk): reforça autostart e recuperação do serviço
This commit is contained in:
parent
a1436ea729
commit
463c0aeccd
2 changed files with 25 additions and 0 deletions
|
|
@ -405,6 +405,12 @@ fn derive_numeric_id(machine_id: &str) -> String {
|
|||
fn ensure_service_running(exe_path: &Path) -> Result<(), RustdeskError> {
|
||||
ensure_service_installed(exe_path)?;
|
||||
|
||||
if let Err(error) = configure_service_startup() {
|
||||
log_event(&format!(
|
||||
"Aviso: não foi possível reforçar autostart/recuperação do serviço RustDesk: {error}"
|
||||
));
|
||||
}
|
||||
|
||||
fn start_sequence() -> Result<(), RustdeskError> {
|
||||
let _ = run_sc(&["stop", SERVICE_NAME]);
|
||||
thread::sleep(Duration::from_secs(2));
|
||||
|
|
@ -427,6 +433,24 @@ fn ensure_service_running(exe_path: &Path) -> Result<(), RustdeskError> {
|
|||
}
|
||||
}
|
||||
|
||||
fn configure_service_startup() -> Result<(), RustdeskError> {
|
||||
let start_arg = format!("start= {}", "auto");
|
||||
run_sc(&["config", SERVICE_NAME, &start_arg])?;
|
||||
|
||||
let reset_arg = format!("reset= {}", "86400");
|
||||
let actions_arg = "actions= restart/5000/restart/5000/restart/5000";
|
||||
let failure_actions_applied = run_sc(&["failure", SERVICE_NAME, &reset_arg, actions_arg]).is_ok();
|
||||
let _ = run_sc(&["failureflag", SERVICE_NAME, "1"]);
|
||||
|
||||
if failure_actions_applied {
|
||||
log_event("Serviço RustDesk configurado para reiniciar automaticamente em caso de falha");
|
||||
} else {
|
||||
log_event("Aviso: não foi possível configurar recuperação automática do serviço RustDesk");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn stop_rustdesk_processes() -> Result<(), RustdeskError> {
|
||||
if let Err(error) = try_stop_service() {
|
||||
log_event(&format!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue