Skip to content

Commit

Permalink
fix(native-app): add failure actions for service
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill committed Sep 25, 2022
1 parent 59e689a commit e12ed5f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions native-app/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ use std::path::PathBuf;
use std::thread;
use std::time::Duration;

use windows_service::service::ServiceAction;
use windows_service::service::ServiceActionType;
use windows_service::service::ServiceFailureActions;
use windows_service::service::ServiceFailureResetPeriod;
use windows_service::{
service::{
Service, ServiceAccess, ServiceDependency, ServiceErrorControl, ServiceInfo,
Expand Down Expand Up @@ -92,6 +96,28 @@ pub fn install_service(executable_path: PathBuf) -> ServiceResult<()> {
service.change_config(&service_info)?;
service.set_description("Companion service for Mystic Light Browser Cinema extension")?;

let actions = vec![
ServiceAction {
action_type: ServiceActionType::Restart,
delay: Duration::from_secs(60),
},
ServiceAction {
action_type: ServiceActionType::Restart,
delay: Duration::from_secs(300),
},
ServiceAction {
action_type: ServiceActionType::None,
delay: Duration::default(),
},
];

service.update_failure_actions(ServiceFailureActions {
reset_period: ServiceFailureResetPeriod::After(Duration::from_secs(60)),
actions: Some(actions),
command: None,
reboot_msg: None,
})?;

tracing::info!("Installing successful");

tracing::info!("Starting the service");
Expand Down

0 comments on commit e12ed5f

Please sign in to comment.