The clock module is responsible for the clock process type. The clock process schedules tasks to run at scheduled time intervals in your worker processes. The clock module is used by e.g. the Triggers and the Scheduler module. The clock module guarantees to schedule tasks without skipping an interval.
Tip: explicitly set the
TZ environment to your time zone and align this with the time zone set in your datastore. This to avoid any issues with dates and their time zones.
Because the clock process might at some point restart or crash and potentially skip a scheduled task, the clock process checks at start-up, if it skipped any task based on the date of the previous executed task. If it identifies a skipped task, it'll schedule the task immediately.
For example, consider a task which sends a mail to all users every month at the 1st day of the month at 13:00 hour exactly. If the clock process crashes at 12:59 hour and starts again at 13:01 the time interval was skipped. The clock module recognizes this and schedules the task at 13:01 instead.
(When the clock module starts the first time, and there are no results, it inserts a fake clock result).
You generally do not need to manually use this Clock module. The Clock module is used by Schedulers and Triggers. If you want to run the clock process, define the below in your Procfile (this is automatically added when creating triggers or schedulers).
clock: node index.js --clock
addTask(timingPattern, taskName, callback)
Creates a task to run at a time interval. The callback is guaranteed to run. The callback should schedule a job on a worker process and not actually execute any work.
Please have a look at the Schedule and Trigger modules if you want to execute work on a worker process.
Name Type Description
A cron-style timing pattern. For more information, see https://github.com/ncb000gt/node-cron.
The name of the task to run.
The function which schedules a job on a worker process.
Stops all the tasks. This is executed when the app is killed.