A cronjob manager. This class is used by the cron weenie function to manage cronjobs. It can also be used directly.

Note that if this class is used in conjunction with weenie's serviceManager, it will kill all cronjobs on SIGINT and SIGTERM (if the serviceManager is configured to handle those signals).

Additionally note that you can delay the registering and starting of cronjobs until all dependencies are successfully registered and initialized by passing a promise to the constructor. If you don't pass a promise, cronjobs that are registered will be started immediately.

Implements

Constructors

Properties

Methods

Constructors

  • Parameters

    • log: SimpleLoggerInterface

      A logger for the cron system to use

    • Optional initWait: Promise<unknown>

      An optional promise used to await initialization of cronjobs

    • Optional onShutdown: ((task) => void)

      An optional function used to shut down all cronjobs on service shutdown

        • (task): void
        • Parameters

          • task: (() => Promise<void>)
              • (): Promise<void>
              • Returns Promise<void>

          Returns void

    Returns Cron

Properties

crontab: {
    [name: string]: {
        job: CronjobInterface;
        provider: CronJob | null;
    };
} = {}

Tracks active cronjobs

Type declaration

ready: boolean = false

Captures the initialization timeout

log: SimpleLoggerInterface

A logger for the cron system to use

initWait?: Promise<unknown>

An optional promise used to await initialization of cronjobs

Methods

Generated using TypeDoc