SCHEDULED TASKS

The ColdBox Scheduled Tasks offers a fresh, programmatic, human approach to scheduling tasks on your server and multi-server application. It allows you to define your tasks in a portable Scheduler we lovingly call the Scheduler.cfc which not only can be used to define your tasks but also monitor all of their life cycles and metrics of tasks. Since ColdBox is also hierarchical, it allows every single ColdBox Module to define a Scheduler and register their tasks. This is a revolutionary approach to scheduling tasks in an HMVC application.
/**
* --------------------------------------------------------------------------
* Register Scheduled Tasks
* --------------------------------------------------------------------------
* You register tasks with the task() method and get back a ColdBoxScheduledTask object
* that you can use to register your tasks configurations.
*/
task( "Clear Unregistered Users" )
.call( () => getInstance( "UserService" ).clearRecentUsers() )
.everyDayAt( "09:00" )
task( "Hearbeat" )
.call( () => runEvent( "main.heartbeat" ) )
.every( 5, "minutes" )
.onFailure( ( task, exception ) => {
getInstance( "System" ).sendBadHeartbeat( exception )
} )
/**
* --------------------------------------------------------------------------
* Task Closure/Lambda/Object
* --------------------------------------------------------------------------
* You register the callable event via the call() method on the task object.
* You can register a closure/lambda or a invokable CFC.
*/
// Object with run() method
task( "my-task" )
.call( wirebox.getInstance( "MyObject" ) )
.everyDay()
// Object with a custom method
task( "my-task" )
.call( wirebox.getInstance( "MyObject" ), "reapCache" )
.everydayAt( "13:00" )