1
0
Fork 0
mirror of synced 2024-06-02 18:44:54 +12:00

Adding backup queue to bullboard if enabled.

This commit is contained in:
mike12345567 2022-10-26 18:50:40 +01:00
parent 52d9172060
commit 80d4220cb5
2 changed files with 29 additions and 20 deletions

View file

@ -54,19 +54,6 @@ app.use(
})
)
app.use(pino(pinoSettings()))
if (!env.isTest()) {
const plugin = bullboard.init()
app.use(plugin)
}
app.context.eventEmitter = eventEmitter
app.context.auth = {}
// api routes
app.use(api.router.routes())
if (env.isProd()) {
env._set("NODE_ENV", "production")
Sentry.init()
@ -104,7 +91,22 @@ server.on("close", async () => {
}
})
const initPro = async () => {
async function initRoutes() {
app.use(pino(pinoSettings()))
if (!env.isTest()) {
const plugin = await bullboard.init()
app.use(plugin)
}
app.context.eventEmitter = eventEmitter
app.context.auth = {}
// api routes
app.use(api.router.routes())
}
async function initPro() {
await pro.init({
backups: {
processing: {
@ -179,11 +181,13 @@ module.exports = server.listen(env.PORT || 0, async () => {
// check for version updates
await installation.checkInstallVersion()
// done last - these will never complete
let promises = []
promises.push(automations.init())
promises.push(initPro())
await Promise.all(promises)
// get the references to the queue promises, don't await as
// they will never end, unless the processing stops
let queuePromises = []
queuePromises.push(automations.init())
queuePromises.push(initPro())
// bring routes online as final step once everything ready
await initRoutes()
})
const shutdown = () => {

View file

@ -3,6 +3,7 @@ const { BullAdapter } = require("@bull-board/api/bullAdapter")
const { KoaAdapter } = require("@bull-board/koa")
const { queue } = require("@budibase/backend-core")
const automation = require("../threads/automation")
const { backups } = require("@budibase/pro")
let automationQueue = queue.createQueue(
queue.JobQueue.AUTOMATION,
@ -11,9 +12,13 @@ let automationQueue = queue.createQueue(
const PATH_PREFIX = "/bulladmin"
exports.init = () => {
exports.init = async () => {
// Set up queues for bull board admin
const backupQueue = await backups.getBackupQueue()
const queues = [automationQueue]
if (backupQueue) {
queues.push(backupQueue)
}
const adapters = []
const serverAdapter = new KoaAdapter()
for (let queue of queues) {