about summary refs log tree commit diff stats
path: root/src/service.rs
diff options
context:
space:
mode:
authoryuzu <yuzu@b9215c17-b818-4693-b096-d1e41a411fef>2025-07-12 06:17:38 +0000
committeryuzu <yuzu@b9215c17-b818-4693-b096-d1e41a411fef>2025-07-12 06:17:38 +0000
commit78608add1c69a877b76a05147f6c26b7abe66669 (patch)
treeb2930fbf3c8e5f6bf2f5eb00f260b5b5092e09bb /src/service.rs
parentbc0fac1bf2a02c9a76c8c4b9eccc9235de4e86b2 (diff)
downloadsalaryman-78608add1c69a877b76a05147f6c26b7abe66669.tar.gz
salaryman-78608add1c69a877b76a05147f6c26b7abe66669.tar.bz2
salaryman-78608add1c69a877b76a05147f6c26b7abe66669.zip
add start, stop, restart endpoints
git-svn-id: svn+ssh://diminuette.aengel.lesbianunix.dev/salaryman/trunk@14 b9215c17-b818-4693-b096-d1e41a411fef
Diffstat (limited to 'src/service.rs')
-rw-r--r--src/service.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/service.rs b/src/service.rs
index dee6e59..22cf9c4 100644
--- a/src/service.rs
+++ b/src/service.rs
@@ -149,6 +149,17 @@ impl Service {
         Ok(())
     }
     /**
+     *  Calls self.start(), then self.scan_stdout(), and finally self.scan_stderr()
+     */
+    #[inline]
+    pub async fn start_with_output(&mut self) -> Result<(), Box<dyn std::error::Error>> {
+        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.
      */
     pub async fn started(&self) -> bool {
@@ -176,12 +187,22 @@ impl Service {
     /**
      *  Restarts service process
      */
+    #[inline]
     pub async fn restart(&mut self) -> Result<(), Box<dyn std::error::Error>> {
         self.stop().await?;
         self.start().await?;
         Ok(())
     }
     /**
+     *  Restarts service process
+     */
+    #[inline]
+    pub async fn restart_with_output(&mut self) -> Result<(), Box<dyn std::error::Error>> {
+        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.
      */