Class BatchProcess

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

Hierarchy

  • BatchProcess

Constructors

  • Parameters

    • proc: ChildProcess
    • opts: InternalBatchProcessOptions
    • onIdle: (() => void)

      to be called when internal state changes (like the current task is resolved, or the process exits)

        • (): void
        • Returns void

    Returns BatchProcess

Properties

failedTaskCount: number = 0
name: string
opts: InternalBatchProcessOptions
pid: number
proc: ChildProcess
start: number = ...
startupTaskId: number

Accessors

  • get ended(): boolean
  • Returns

    true if this.end() has completed running, which includes child process cleanup. Note that this may return true and the process table may still include the child pid. Call .running() for an authoritative (but expensive!) answer.

    Returns boolean

  • get ending(): boolean
  • Returns

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

    Returns boolean

  • get exited(): boolean
  • Returns

    true if the child process has exited and is no longer in the process table. Note that this may be erroneously false if the process table hasn't been checked. Call .running() for an authoritative (but expensive!) answer.

    Returns boolean

  • get healthy(): boolean
  • Returns

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

    Returns boolean

  • get idle(): boolean
  • Returns

    true iff no current task. Does not take into consideration if the process has ended or should be recycled: see ready.

    Returns boolean

  • get ready(): boolean
  • Returns

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

    Returns boolean

  • get whyNotHealthy(): null | WhyNotHealthy
  • Returns

    a string describing why this process should be recycled, or null if the process passes all health checks. Note that this doesn't include if we're already busy: see whyNotReady if you need to know if a process can handle a new task.

    Returns null | WhyNotHealthy

  • get whyNotReady(): null | WhyNotReady
  • Returns

    a string describing why this process cannot currently handle a new task, or undefined if this process is idle and healthy.

    Returns null | WhyNotReady

Methods

  • End this child process.

    Returns

    Promise that will be resolved when the process has completed. Subsequent calls to end() will ignore the parameters and return the first endPromise.

    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>

  • Returns

    true if the child process is in the process table

    Returns Promise<boolean>

Generated using TypeDoc