Utilities for scheduled tasks

Back: Functional utilities of the application

Utilities for scheduled tasks (jobs) are designed to automate the regular execution of certain actions at certain intervals.
To do this, each utility must be defined in the deploy.json application in the globals.jobs object, for example:

di should contain a field with a name equal to the value of worker - this is the task that will be launched.

Here the script runs on a schedule applications/khv-ticket-discount/lib/overnightTicketClose.js. launch can be an object containing the following fields:
month, week, day, dayOfYear, weekday, hour, min, minute, sec, second - they set the interval between task completion;
check - the interval for checking the execution condition, in milliseconds, is 1000 by default.
For example, if check is 5000 and sec is 2, the task will be executed only every 10 seconds when the interval between checks coincides with the execution interval
If the task execution interval is not set, it will be completed when the application starts and after each verification interval.
- time in milliseconds after which a running task is interrupted by timeout;

launch can also be an integer - the interval of the task in milliseconds, while the task will also be performed immediately when the application starts. The timeout will be set equal to the execution interval.

In the options field, any variables and their values can be specified, which will become available in the script through the fields of the object passed as an argument to the main function of the module.

The script is compiled in the module format, for example: