MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / resolveDaemonTarget

Function resolveDaemonTarget

apps/cli/src/main.ts:455–484  ·  view source on GitHub ↗
(baseUrl: string)

Source from the content-addressed store, hash-verified

453 });
454
455const resolveDaemonTarget = (baseUrl: string) =>
456 Effect.gen(function* () {
457 const parsed = yield* parseDaemonUrl(baseUrl);
458 const host = canonicalDaemonHost(parsed.hostname);
459 const scopeId = currentDaemonScopeId();
460 const pointer = yield* readDaemonPointer({ hostname: host, scopeId });
461
462 if (pointer) {
463 const pointerUrl = daemonBaseUrl(pointer.hostname, pointer.port);
464 if (isPidAlive(pointer.pid) && (yield* isServerReachable(pointerUrl))) {
465 return {
466 baseUrl: pointerUrl,
467 hostname: pointer.hostname,
468 port: pointer.port,
469 scopeId,
470 fromPointer: true,
471 };
472 }
473
474 yield* cleanupPointer({ hostname: pointer.hostname, scopeId, port: pointer.port });
475 }
476
477 return {
478 baseUrl: daemonBaseUrl(host, parsed.port),
479 hostname: host,
480 port: parsed.port,
481 scopeId,
482 fromPointer: false,
483 };
484 });
485
486const waitForDaemonStartupTarget = (input: {
487 readonly requestedBaseUrl: string;

Callers 4

ensureDaemonFunction · 0.85
stopDaemonFunction · 0.85
runBackgroundDaemonStartFunction · 0.85
main.tsFile · 0.85

Calls 8

canonicalDaemonHostFunction · 0.90
currentDaemonScopeIdFunction · 0.90
readDaemonPointerFunction · 0.90
isPidAliveFunction · 0.90
parseDaemonUrlFunction · 0.85
daemonBaseUrlFunction · 0.85
isServerReachableFunction · 0.85
cleanupPointerFunction · 0.85

Tested by

no test coverage detected