Skip to content

Commit

Permalink
feat: Use nssm for service registration
Browse files Browse the repository at this point in the history
  • Loading branch information
DPS0340 committed Jul 1, 2024
1 parent 66cd401 commit e2dfda8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/executor/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ WantedBy=multi-user.target"#;

#[cfg(target_os = "windows")]
async fn create_daemon_config_if_not_exists(&self) -> Result<(), RRDBError> {
let output = Command::new("sc.exe").args(["create", "rrdb", "binpath=", r"'C:\Program Files\rrdb\rrdb.exe'"]).output();
Command::new("winget").args(["install", "--accept-package-agreements", "nssm"]);

let output = Command::new("nssm.exe").args(["install", "rrdb", "C:\\Program Files\\rrdb\\rrdb.exe", "run"]).output();

self.check_output_status(output)
}
Expand Down Expand Up @@ -181,7 +183,7 @@ WantedBy=multi-user.target"#;

#[cfg(target_os = "windows")]
fn get_daemon_start_command(&self) -> (&'static str, Vec<&'static str>) {
("sc.exe", vec!["start", "rrdb", "run"])
("sc.exe", vec!["start", "rrdb"])
}

fn check_output_status(&self, output: Result<Output, Error>) -> Result<(), RRDBError> {
Expand Down

0 comments on commit e2dfda8

Please sign in to comment.