batch-cluster
    Preparing search index...

    Class BatchProcess

    BatchProcess manages the care and feeding of a single child process.

    Index
    failedTaskCount: number = 0
    name: string
    pid: number
    proc: ChildProcess
    start: number = ...
    startupTaskId: number
    • get currentTask(): Task<unknown> | undefined

      Getter for current task (required by StreamContext interface)

      Returns Task<unknown> | undefined

    • get ended(): boolean

      Returns boolean

      true if this.end() has completed running, which includes child process cleanup. A failed termination also settles end(); use exited to distinguish confirmed exit, and await end() to receive cleanup errors.

    • get ending(): boolean

      Returns boolean

      true if this.end() has been requested (which may be due to the child process exiting)

    • get exitCode(): number | null

      Exit code from the child process, or null if not yet exited. Populated for both expected terminations (idle, old, worn) and unexpected exits (crashes, errors). Use unexpectedExit to determine if the exit was unexpected.

      Returns number | null

    • get exited(): boolean

      Returns boolean

      true if the child process has exited (based on OS events). This is now authoritative and inexpensive since it's driven by OS events rather than polling.

    • get exitSignal(): Signals | null

      Exit signal from the child process, or null if not terminated by signal. Populated for both expected terminations and unexpected exits. Use unexpectedExit to determine if the exit was unexpected.

      Returns Signals | null

    • get healthy(): boolean

      Returns boolean

      true if the process doesn't need to be recycled.

    • get ready(): boolean

      Returns boolean

      true iff this process is both healthy and idle, and ready for a new task.

    • get retirementRequested(): boolean

      Whether this worker has been asked to retire after its current task.

      Returns boolean

    • get unexpectedExit(): boolean

      Returns true if the process exited unexpectedly (crash, error, timeout, etc.) rather than through proactive cluster management (worn, old, idle, etc.). Useful for determining if a non-zero exit code indicates a problem.

      Returns boolean

      ExpectedTerminationReasons for the list of expected termination reasons.

    • Reject the task this process was running when it was told to end, if termination hasn't settled it yet.

      ProcessTerminator gives that task up to 2 seconds to finish on its own, which is longer than a bounded shutdown may be willing to wait. Without this, end() can resolve -- and the caller process.exit() -- while that promise is still pending, which abandons it entirely.

      Parameters

      • reason: string

      Returns boolean

      true if a pending task was rejected.

    • End this child process.

      Parameters

      • gracefully: boolean = true

        Wait for any current task to be resolved or rejected before shutting down the child process.

      • reason: WhyNotHealthy

        who called end() (used for logging)

      Returns Promise<void>

      Promise that resolves after the child exits, or rejects if it is still running 5 seconds after termination. Subsequent calls to end() will ignore the parameters and return the first endPromise.

    • Permanently prevent further assignments while letting the active task settle under its normal timeout. Idle workers are recycled immediately. Repeated calls have no additional effect. Unlike end(), this preserves the current task and its output streams until the task settles.

      Returns void

    • Returns boolean

      true if the child process is running. Now event-driven first with polling fallback.