2021-09-07 20:06:20 +02:00
|
|
|
const { processEvent } = require("./utils")
|
2022-05-30 22:22:06 +02:00
|
|
|
const { queue, shutdown } = require("./bullboard")
|
2022-09-07 18:05:17 +02:00
|
|
|
const { TRIGGER_DEFINITIONS, rebootTrigger } = require("./triggers")
|
2022-04-06 13:34:31 +02:00
|
|
|
const { ACTION_DEFINITIONS } = require("./actions")
|
2020-10-07 18:56:47 +02:00
|
|
|
|
2020-09-11 19:47:22 +02:00
|
|
|
/**
|
|
|
|
* This module is built purely to kick off the worker farm and manage the inputs/outputs
|
|
|
|
*/
|
2022-09-07 18:05:17 +02:00
|
|
|
exports.init = async function () {
|
2021-09-08 20:29:28 +02:00
|
|
|
// this promise will not complete
|
2022-09-07 18:05:17 +02:00
|
|
|
const promise = queue.process(async job => {
|
2021-09-07 20:06:20 +02:00
|
|
|
await processEvent(job)
|
2020-09-10 16:00:21 +02:00
|
|
|
})
|
2022-09-07 18:05:17 +02:00
|
|
|
// on init we need to trigger any reboot automations
|
|
|
|
await rebootTrigger()
|
|
|
|
return promise
|
2020-09-10 16:00:21 +02:00
|
|
|
}
|
2021-09-08 20:29:28 +02:00
|
|
|
|
|
|
|
exports.getQueues = () => {
|
|
|
|
return [queue]
|
|
|
|
}
|
2022-04-06 13:34:31 +02:00
|
|
|
|
2022-05-30 22:22:06 +02:00
|
|
|
exports.shutdown = () => {
|
|
|
|
return shutdown()
|
|
|
|
}
|
|
|
|
|
2021-09-08 20:29:28 +02:00
|
|
|
exports.queue = queue
|
2022-04-06 13:34:31 +02:00
|
|
|
exports.TRIGGER_DEFINITIONS = TRIGGER_DEFINITIONS
|
|
|
|
exports.ACTION_DEFINITIONS = ACTION_DEFINITIONS
|