Files
speckle-server/packages/server/modules/cli/commands/bull/monitor.ts
T
Iain Sproat 444d2ca7dd Structured logging (attempt 2) (#1234)
* Revert "Revert "feat(structured logging): implements structured logging for backend (#1217)" (#1227)"

This reverts commit 63e6581162.

* Use pino-http instead of express pino logger
* Use correct reference to knex and do not instantiate HttpLogger prematurely
* Adds missing dependency for pino to webhook-service
* Do not instantiate middleware when passed to express
* Refactor to move logging into shared
* Copy shared packages into dockerfiles
* Build shared workspace in docker build-stage for fileimport & webhook
2022-12-05 14:49:52 +00:00

60 lines
1.6 KiB
TypeScript

import { CommandModule } from 'yargs'
import express from 'express'
import { ExpressAdapter } from '@bull-board/express'
import { createBullBoard } from '@bull-board/api'
import { BullAdapter } from '@bull-board/api/bullAdapter'
import {
NOTIFICATIONS_QUEUE,
buildNotificationsQueue
} from '@/modules/notifications/services/queue'
import { noop } from 'lodash'
import { cliLogger } from '@/logging/logging'
const PORT = 3032
const command: CommandModule<unknown, { testQueueId: string }> = {
command: 'monitor [testQueueId]',
describe: 'Run bull-board monitoring web UI',
builder: {
testQueueId: {
describe:
'Optionally specify the ID of a test queue (from a test run) to load it as well',
type: 'string'
}
},
handler: async (argv) => {
const testQueueId = argv.testQueueId
cliLogger.info('Initializing bull queues...')
const queues = [buildNotificationsQueue(NOTIFICATIONS_QUEUE)]
if (testQueueId) {
cliLogger.info('Also initializing queue %s...', testQueueId)
queues.push(buildNotificationsQueue(testQueueId))
}
cliLogger.info('Initializing monitor...')
const app = express()
const serverAdapter = new ExpressAdapter()
createBullBoard({
serverAdapter,
queues: Object.values(queues).map((q) => new BullAdapter(q))
})
app.use(serverAdapter.getRouter())
app.listen(PORT, () => {
cliLogger.info(`Running on ${PORT}...`)
cliLogger.info(
`For the UI, open http://localhost:${PORT}/, and make sure Redis is running`
)
})
// Waiting forever
await new Promise(noop)
}
}
export = command