From 78608add1c69a877b76a05147f6c26b7abe66669 Mon Sep 17 00:00:00 2001 From: yuzu Date: Sat, 12 Jul 2025 06:17:38 +0000 Subject: add start, stop, restart endpoints git-svn-id: svn+ssh://diminuette.aengel.lesbianunix.dev/salaryman/trunk@14 b9215c17-b818-4693-b096-d1e41a411fef --- src/service.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/service.rs') diff --git a/src/service.rs b/src/service.rs index dee6e59..22cf9c4 100644 --- a/src/service.rs +++ b/src/service.rs @@ -148,6 +148,17 @@ impl Service { self.proc = Some(Arc::new(Mutex::new(child))); Ok(()) } + /** + * Calls self.start(), then self.scan_stdout(), and finally self.scan_stderr() + */ + #[inline] + pub async fn start_with_output(&mut self) -> Result<(), Box> { + self.start().await?; + self.scan_stdout().await?; + self.scan_stderr().await?; + Ok(()) + } + //TODO: process monitoring! /** * Returns true when process is started and false when process is stopped. */ @@ -176,11 +187,21 @@ impl Service { /** * Restarts service process */ + #[inline] pub async fn restart(&mut self) -> Result<(), Box> { self.stop().await?; self.start().await?; Ok(()) } + /** + * Restarts service process + */ + #[inline] + pub async fn restart_with_output(&mut self) -> Result<(), Box> { + self.stop().await?; + self.start_with_output().await?; + Ok(()) + } /** * Takes control of service process' stdout file handle and spawns a new task to continuously * scan it. -- cgit 1.4.1-2-gfad0