wilton/CronTask
Run periodic tasks in background.
More...
Functions | |
Object | CronTask (Object options, Function|Undefined callback) |
Create CronTask instance. | |
Undefined | stop (Function|Undefined callback) |
Stop periodic execution of a background task. |
This module allows to run tasks in background, starting them periodically specifying startup times using Cron expression.
It uses extended version of Cron
expressions with support for seconds field.
Each CronTask
instance starts a background thread that is used to run specified function.
To release system resources, CronTask
instance can be stopped manually using stop()
method, or it will be closed during the shutdown.
Usage example:
Object CronTask::CronTask | ( | Object | options, |
Function|Undefined | callback | ||
) |
Creates task instance and starts background thread.
options | Object configuration object, see possible options below |
callback | Function|Undefined callback to receive result or error |
Object
CronTask
instanceOptions
String
Cron expression, see expression formatObject
module path and function name to run from background threadString
full name of JavaScript module to loadString|Undefined
name of the function contained in the specified module, if function is not specified, only module will be loaded (its top-level code will be executed)Array|Undefined
optional list of arguments, that will be passed to specified function Undefined CronTask::stop | ( | Function|Undefined | callback | ) |
Stops the background thread releasing system resources.
callback | Function|Undefined callback to receive result or error |
Undefined