Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

serviceLauncher.ts

23 lines873 Bytes

1import * as Effect from "effect/Effect";
2import { Command } from "effect/cli";
3​
4import { main as runServiceLauncher } from "../serviceLauncher.ts";
5​
6/**
7 * The launcher owns SIGTERM handling and the process lifetime: it must finish stopping its child
8 * before the process exits, so it runs detached from the CLI's fiber rather than under `runMain`,
9 * whose signal handler would interrupt the fiber and exit while the child is still being
10 * terminated.
11 */
12export const serviceLauncherCommand = Command.make("__service-launcher").pipe(
13 Command.unlisted,
14 Command.withHandler(() =>
15 Effect.sync(() => {
16 runServiceLauncher().catch((cause: unknown) => {
17 const error = cause instanceof Error ? cause : new Error(String(cause));
18 process.stderr.write(`[service-launcher] ${error.message}\n`);
19 process.exitCode = 1;
20 });
21 }),
22 ),
23);