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

Function resolveDaemonTarget

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

Source from the content-addressed store, hash-verified

436 });
437
438const resolveDaemonTarget = (baseUrl: string) =>
439 Effect.gen(function* () {
440 const parsed = yield* parseDaemonUrl(baseUrl);
441 const host = canonicalDaemonHost(parsed.hostname);
442 const scopeId = currentDaemonScopeId();
443 const pointer = yield* readDaemonPointer({ hostname: host, scopeId });
444
445 if (pointer) {
446 const pointerUrl = daemonBaseUrl(pointer.hostname, pointer.port);
447 if (isPidAlive(pointer.pid) && (yield* isServerReachable(pointerUrl))) {
448 return {
449 baseUrl: pointerUrl,
450 hostname: pointer.hostname,
451 port: pointer.port,
452 scopeId,
453 fromPointer: true,
454 };
455 }
456
457 yield* cleanupPointer({ hostname: pointer.hostname, scopeId, port: pointer.port });
458 }
459
460 return {
461 baseUrl: daemonBaseUrl(host, parsed.port),
462 hostname: host,
463 port: parsed.port,
464 scopeId,
465 fromPointer: false,
466 };
467 });
468
469const waitForDaemonStartupTarget = (input: {
470 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