Hyperlinkv0.9.0-beta.0

Launcher

export const spawn = (
  spec: SpawnSpec,
): Effect.Effect<
  Handle,
  PlatformError,
  ChildProcessSpawner.ChildProcessSpawner | Scope.Scope
> =>
  withLauncherPhase(
    spec.node.key,
    "spawn",
    Effect.gen(function* () {
      const token = yield* mintToken;
      const clear = Redacted.value(token);
      const command =
        typeof spec.process === "function" ? spec.process(clear) : spec.process;
      const child = yield* command;
      const phase = yield* Ref.make<HandlePhase>("spawned");
      const gate = yield* Semaphore.make(1);
      yield* Effect.logInfo("child spawned under launcher custody").pipe(
        Effect.annotateLogs({ "launcher.pid": String(child.pid) }),
      );
      return makeHandle({
        node: spec.node,
        token,
        child,
        ready: spec.ready,
        phase,
        gate,
      });
    }),
  );
Referenced by 1 symbols