1/**
2 * Node.js process runner for Effect programs.
3 *
4 * This module exports `runMain`, which runs one Effect as the main process
5 * fiber in Node.js. It reuses the shared Node runtime runner, including its
6 * error reporting, `SIGINT` / `SIGTERM` interruption, and optional teardown
7 * behavior.
8 *
9 * @since 4.0.0
10 */
11import * as NodeRuntime from "@effect/platform-node-shared/NodeRuntime"
12import type { Effect } from "effect/Effect"
13import type * as Runtime from "effect/Runtime"
14
15/**
16 * Helps you run a main effect with built-in error handling, logging, and signal management.
17 *
18 * **When to use**
19 *
20 * Use to run a Node.js application's main Effect with structured error
21 * handling, log management, interrupt support, or advanced teardown
22 * capabilities.
23 *
24 * **Details**
25 *
26 * This function launches an Effect as the main entry point, setting exit codes
27 * based on success or failure, handling interrupts (e.g., Ctrl+C), and optionally
28 * logging errors. By default, it logs errors and uses a "pretty" format, but both
29 * behaviors can be turned off. You can also provide custom teardown logic to
30 * finalize resources or produce different exit codes.
31 *
32 * The optional configuration object can include:
33 * - `disableErrorReporting`: Turn off automatic error logging.
34 * - `teardown`: Provide custom finalization logic.
35 *
36 * @category running
37 * @since 4.0.0
38 */
39export const runMain: {
40 (
41 options?: {
42 readonly disableErrorReporting?: boolean | undefined
43 readonly teardown?: Runtime.Teardown | undefined
44 }
45 ): <E, A>(effect: Effect<A, E>) => void
46 <E, A>(
47 effect: Effect<A, E>,
48 options?: {
49 readonly disableErrorReporting?: boolean | undefined
50 readonly teardown?: Runtime.Teardown | undefined
51 }
52 ): void
53} = NodeRuntime.runMain