()
| 105 | } |
| 106 | |
| 107 | pub fn active() -> anyhow::Result<Option<ServiceInstallResult>> { |
| 108 | if !launch_agent_supported() { |
| 109 | return Ok(None); |
| 110 | } |
| 111 | let domain = launchctl_domain()?; |
| 112 | if launchagent_pid(&domain, SERVICE_LABEL).is_none() { |
| 113 | return Ok(None); |
| 114 | } |
| 115 | let Some(arguments) = installed_arguments_for_label(SERVICE_LABEL)? else { |
| 116 | return Ok(None); |
| 117 | }; |
| 118 | let plist_path = plist_path()?; |
| 119 | let log_dir = log_dir()?; |
| 120 | let port = argument_value(&arguments, "--port") |
| 121 | .and_then(|value| value.parse::<u16>().ok()) |
| 122 | .unwrap_or(4310); |
| 123 | Ok(Some(ServiceInstallResult { |
| 124 | service: SERVICE_LABEL.to_owned(), |
| 125 | plist_path, |
| 126 | executable_path: installed_executable_path(&arguments), |
| 127 | stdout_log: log_dir.join("simdeck.log"), |
| 128 | stderr_log: log_dir.join("simdeck.err.log"), |
| 129 | port, |
| 130 | advertise_host: argument_value(&arguments, "--advertise-host"), |
| 131 | access_token: argument_value(&arguments, "--access-token"), |
| 132 | pairing_code: argument_value(&arguments, "--pairing-code"), |
| 133 | reused: true, |
| 134 | })) |
| 135 | } |
| 136 | |
| 137 | fn install(mut options: ServiceOptions) -> anyhow::Result<ServiceInstallResult> { |
| 138 | let plist_path = plist_path()?; |
no test coverage detected