-
Notifications
You must be signed in to change notification settings - Fork 21
Job Scheduling
The HAPI platform features an in-process scheduler for running periodic jobs. Jobs can be control functions, such as turning a light or pump on. Jobs can also serve monitoring purposes, such as gathering sensor data. Job information is stored in the database, in the table schedule
. Any Smart Module can run the job scheduling code (i.e. "become the Scheduler"). HAPI Nodes cannot become the Scheduler.
When a Smart Module starts, it publishes on message on the MQTT topic SCHEDULER/QUERY, essentially asking for the Scheduler to respond. If another module on the network is running the job scheduling code, it responds to the to the message and no further action is taken. If there is no response to the message, the starting module runs the job scheduling code itself, announces that it is now the Scheduler and listens on the SCHEDULER/QUERY topic for other Smart Modules that are discovering the scheduler.
The HAPI Scheduler uses the schedule package created by Daniel Badr. Documentation can be found here.