MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / reuse_running_service_if_matching

Function reuse_running_service_if_matching

packages/server/src/service.rs:268–301  ·  view source on GitHub ↗
(
    options: &ServiceOptions,
)

Source from the content-addressed store, hash-verified

266}
267
268fn 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)]
304enum ServiceEnableAction {

Callers 2

enableFunction · 0.85
pairFunction · 0.85

Calls 9

launchctl_domainFunction · 0.85
launchagent_pidFunction · 0.85
default_client_rootFunction · 0.85
plist_pathFunction · 0.85
log_dirFunction · 0.85
cloneMethod · 0.65

Tested by

no test coverage detected