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

Function resolveDaemonTarget

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

Source from the content-addressed store, hash-verified

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