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

Function stop_project_service

packages/server/src/main.rs:1507–1529  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1505}
1506
1507fn stop_project_service() -> anyhow::Result<()> {
1508 let active = service::active()?;
1509 let Some(metadata) = read_service_metadata()? else {
1510 if active.is_some() {
1511 return service::disable();
1512 }
1513 println_json(&serde_json::json!({ "ok": true, "running": false }))?;
1514 return Ok(());
1515 };
1516 if active
1517 .as_ref()
1518 .is_some_and(|result| result.port == metadata.port)
1519 {
1520 return service::disable();
1521 }
1522 terminate_service_metadata(&metadata)?;
1523 println_json(&serde_json::json!({
1524 "ok": true,
1525 "running": false,
1526 "pid": metadata.pid,
1527 "killedPid": metadata.pid
1528 }))
1529}
1530
1531fn terminate_service_metadata(metadata: &ServiceMetadata) -> anyhow::Result<()> {
1532 terminate_process_group(metadata.pid, Duration::from_secs(5));

Callers 1

mainFunction · 0.85

Calls 5

activeFunction · 0.85
read_service_metadataFunction · 0.85
disableFunction · 0.85
println_jsonFunction · 0.85

Tested by

no test coverage detected