MCPcopy
hub / github.com/CapSoftware/Cap / main

Function main

apps/desktop/scripts/desktop-memory-soak.js:415–578  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

413}
414
415async function main() {
416 if (process.platform !== "darwin") {
417 console.error("This soak test only supports macOS.");
418 process.exit(1);
419 }
420
421 const options = parseArgs(process.argv.slice(2));
422
423 if (options.help) {
424 printHelp();
425 return;
426 }
427
428 const existingTargetProcess = findCapMainProcess(
429 readProcesses(),
430 options.appCommandPrefix,
431 );
432 if (existingTargetProcess) {
433 throw new Error(
434 `Quit the target app before running the soak test: ${options.appCommandPrefix}`,
435 );
436 }
437
438 const otherCapProcesses = listOtherCapProcesses(options);
439 if (otherCapProcesses.length > 0) {
440 throw new Error(
441 `Quit other Cap processes before running the soak test: ${otherCapProcesses.map((processInfo) => processInfo.command).join(", ")}`,
442 );
443 }
444
445 let originalStoreContents = null;
446 let child = null;
447 let cleanupStarted = false;
448 const rl = options.manual
449 ? createInterface({
450 input: process.stdin,
451 output: process.stdout,
452 })
453 : null;
454
455 const cleanup = async () => {
456 if (cleanupStarted) return;
457 cleanupStarted = true;
458 await stopChild(child, options.stopTimeoutSeconds);
459 if (originalStoreContents !== null) {
460 restoreStore(options.storePath, originalStoreContents);
461 }
462 };
463
464 for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
465 process.on(signal, () => {
466 cleanup()
467 .then(() => process.exit(1))
468 .catch((error) => {
469 console.error(error instanceof Error ? error.message : String(error));
470 process.exit(1);
471 });
472 });

Callers 1

Calls 15

findCapMainProcessFunction · 0.90
formatMbFunction · 0.90
evaluateCyclesFunction · 0.90
printHelpFunction · 0.85
readProcessesFunction · 0.85
listOtherCapProcessesFunction · 0.85
createInterfaceFunction · 0.85
writeAutomationStoreFunction · 0.85
waitForAppFunction · 0.85
collectPhaseFunction · 0.85
runAutomatedCycleFunction · 0.85
onMethod · 0.80

Tested by

no test coverage detected