Skip to content

Commit

Permalink
Merge pull request #158 from erikh/fix-supervise
Browse files Browse the repository at this point in the history
Fix supervise
  • Loading branch information
erikh committed Feb 23, 2022
2 parents bad93b5 + d25d5e8 commit fe14861
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 1 addition & 7 deletions src/bin/zeronsd.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
use std::time::Duration;

use zeronsd::cli::init;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
init().await?;

loop {
tokio::time::sleep(Duration::MAX).await
}
Ok(init().await?)
}
7 changes: 5 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
supervise::Properties,
};
use log::error;
use std::path::PathBuf;
use std::{path::PathBuf, time::Duration};

use clap::{Args, Parser, Subcommand};

Expand Down Expand Up @@ -106,7 +106,10 @@ pub async fn init() -> Result<(), anyhow::Error> {
let result = match cli.command {
Command::Start(args) => {
start(args).await?;
Ok(())

loop {
tokio::time::sleep(Duration::MAX).await
}
}
Command::Supervise(args) => supervise(args),
Command::Unsupervise(args) => unsupervise(args),
Expand Down
11 changes: 7 additions & 4 deletions src/supervise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use std::path::{Path, PathBuf};

use anyhow::anyhow;
use log::info;
use regex::Regex;
use serde::Serialize;
use tinytemplate::TinyTemplate;
Expand Down Expand Up @@ -389,7 +388,7 @@ impl<'a> Properties {
_ => systemd_help,
};

info!(
eprintln!(
"Service definition written to {}.\n{}",
service_path
.to_str()
Expand All @@ -413,7 +412,7 @@ impl<'a> Properties {
}
};

info!(
eprintln!(
"Service definition written to {}.\nTo start the service, run:\nsudo launchctl load {}",
service_path.to_str().expect("Could not coerce service path to string"),
service_path.to_str().expect("Could not coerce service path to string")
Expand All @@ -438,6 +437,10 @@ impl<'a> Properties {
))
}
};
eprintln!(
"Service definition removed from {}.\nDon't forget to reload systemd:\nsudo systemctl daemon-reload",
self.service_path().to_str().expect("Could not coerce service path to string"),
);
} else if cfg!(target_os = "macos") {
match std::fs::remove_file(self.service_path()) {
Ok(_) => {}
Expand All @@ -452,7 +455,7 @@ impl<'a> Properties {
}
};

info!(
eprintln!(
"Service definition removed from {}.\nDon't forget to stop it:\nsudo launchctl remove {}",
self.service_path().to_str().expect("Could not coerce service path to string"),
self.service_name().replace(".plist", "")
Expand Down

0 comments on commit fe14861

Please sign in to comment.