(&self)
| 99 | } |
| 100 | |
| 101 | fn status(&self) -> Result<ServiceStatus> { |
| 102 | let service_path = self.service_file_path(); |
| 103 | let service_file = Path::new(&service_path); |
| 104 | if !service_file.exists() { |
| 105 | return Ok(ServiceStatus::NotInstalled); |
| 106 | } |
| 107 | |
| 108 | let output = Command::new("systemctl") |
| 109 | .args(["is-active", &self.config.name]) |
| 110 | .output() |
| 111 | .context("Failed to check service status")?; |
| 112 | |
| 113 | let status_str = String::from_utf8_lossy(&output.stdout).trim().to_string(); |
| 114 | |
| 115 | match status_str.as_str() { |
| 116 | "active" => Ok(ServiceStatus::Running), |
| 117 | "inactive" => Ok(ServiceStatus::Stopped), |
| 118 | _ => Ok(ServiceStatus::Unknown), |
| 119 | } |
| 120 | } |
| 121 | } |
no test coverage detected