(
options: &ServiceOptions,
)
| 266 | } |
| 267 | |
| 268 | fn reuse_running_service_if_matching( |
| 269 | options: &ServiceOptions, |
| 270 | ) -> anyhow::Result<Option<ServiceInstallResult>> { |
| 271 | let domain = launchctl_domain()?; |
| 272 | if launchagent_pid(&domain, SERVICE_LABEL).is_none() { |
| 273 | return Ok(None); |
| 274 | } |
| 275 | let Some(arguments) = installed_arguments_for_label(SERVICE_LABEL)? else { |
| 276 | return Ok(None); |
| 277 | }; |
| 278 | let client_root = match options.client_root.as_ref() { |
| 279 | Some(path) => path.clone(), |
| 280 | None => default_client_root()?, |
| 281 | }; |
| 282 | if enable_action_for_installed_arguments(Some(&arguments), options, &client_root) |
| 283 | != ServiceEnableAction::Reuse |
| 284 | { |
| 285 | return Ok(None); |
| 286 | } |
| 287 | let plist_path = plist_path()?; |
| 288 | let log_dir = log_dir()?; |
| 289 | Ok(Some(ServiceInstallResult { |
| 290 | service: SERVICE_LABEL.to_owned(), |
| 291 | plist_path, |
| 292 | executable_path: installed_executable_path(&arguments), |
| 293 | stdout_log: log_dir.join("simdeck.log"), |
| 294 | stderr_log: log_dir.join("simdeck.err.log"), |
| 295 | port: options.port, |
| 296 | advertise_host: options.advertise_host.clone(), |
| 297 | access_token: options.access_token.clone(), |
| 298 | pairing_code: options.pairing_code.clone(), |
| 299 | reused: true, |
| 300 | })) |
| 301 | } |
| 302 | |
| 303 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
| 304 | enum ServiceEnableAction { |
no test coverage detected