\ChronosDaemon
Executor for scheduled tasks. This expects that the scheduled actions defined have been serialised to configuration files that contain the scheduling and action information, per action.
This process is designed to be executed as a daemon. Generally it will sleep, until a scheduled event is
scheduled to occur. It also wakes periodically to refresh its internal copy of the schedule, in case the application
changes it.
Scheduled actions are either once-only or recurring.
Expected usage:
php _execute_schedule.php temp=path
The temp parameter must be set. It is how the executor knows where to find configuration files. By default, this is
the temp folder for the SilverStripe site, in the 'chronos' subdirectory, unless overridden in the site code with
a call to Chronos::set_config_dir().
It also understands the following optional parameters:
- config_refresh=n Specifies the number of seconds between refreshes of the schedule. If not supplied,
defaults to 30 seconds. This is the amount of time the daemon will take to respond
to changes in calendar.
- tolerance=n Specifies the number of seconds of tolerance. A scheduled action will execute if
its date/time is the current time, or up to 'tolerance' seconds late.
- time_limit=n If specified, sets the execution time limit to n seconds. If 0, unlimited time.
Synopsis
- // methods
- public void refreshActionStructure()
- public void determineNextEventFromSchedule()
- public array determinePrevNextRecurrence()
- public void executeDueActions()
- public void execute()
Tasks
Line | Task |
---|---|
109 | take into account byday, byhour, byminute |
183 | These should be logged. |
Members
public
- $confs
- $params
Methods
public
- determineNextEventFromSchedule() — Return the timestamp of the next scheduled action to be executed.
- determinePrevNextRecurrence() — Given a recurring time specification $timeSpec, and a reference time, work out the previous and next occurrence relative to $baseTime.
- execute() — Main execution method for daemon.
- executeDueActions() — Execute all actions that are due to be executed right now. It's also responsible for purging out actions that have been done or are in the past only.
- refreshActionStructure() — Read all the scheduled actions into internal representation. Replaces any existing representation.