Skip to content

Commit

Permalink
feat(bullmq): Replaced Bull Arena with Bull Board
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Oct 7, 2024
1 parent ce9fd6a commit e6762b9
Show file tree
Hide file tree
Showing 20 changed files with 469 additions and 3,231 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ config/development*
.okta.env
system.env
keylog.txt

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ EmailEngine relies on Redis as its data store. Redis stores everything in RAM, s

To diagnose problems:

1. **Check Bull Queues:** Use the built-in Bull Arena UI to monitor queue states at [http://127.0.0.1:3000/admin/arena](http://127.0.0.1:3000/admin/arena).
1. **Check Bull Queues:** Use the built-in Bull Arena UI to monitor queue states at [http://127.0.0.1:3000/admin/bull-board](http://127.0.0.1:3000/admin/bull-board).
2. **Scan Keyspace:** Run the following to group Redis keys by type and generate a report:

```bash
Expand Down
4 changes: 0 additions & 4 deletions copy-static-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ cp node_modules/ace-builds/src-min/snippets/javascript.js static/js/ace/snippets
cp node_modules/ace-builds/src-min/snippets/markdown.js static/js/ace/snippets
cp node_modules/ace-builds/src-min/ext-searchbox.js static/js/ace/ext-searchbox.js

rm -rf static/openapi-themes/
mkdir -p static/openapi-themes/
cp node_modules/swagger-ui-themes/themes/3.x/theme-material.css static/openapi-themes/

wget https://developers.google.com/static/search/apis/ipranges/special-crawlers.json -O data/google-crawlers.json
node -e 'console.log("Google crawlers updated: "+require("./data/google-crawlers.json").creationTime);'

Expand Down
60 changes: 60 additions & 0 deletions lib/api-routes/bull-board-routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict';

const { createBullBoard } = require('@bull-board/api');
const { BullMQAdapter } = require('@bull-board/api/bullMQAdapter');
const { HapiAdapter } = require('@bull-board/hapi');
const { notifyQueue, submitQueue, documentsQueue } = require('../db');

async function init(args) {
const { server } = args;

const serverAdapter = new HapiAdapter();

let queues = [
{
queue: notifyQueue,
prefix: 'Webhooks Queue - ',
description: 'This queue processes all email events that may trigger webhooks. Events that do not trigger a webhook are silently discarded.'
},
{
queue: submitQueue,
prefix: 'Submission Queue - ',
description: 'This queue contains emails that are scheduled to be sent.'
},
{
queue: documentsQueue,
prefix: 'Document Queue - ',
description: '(Deprecated) This queue was used for indexing email information in the Document Store'
}
];
let queueAdapters = queues.map(queue => {
let adapter = new BullMQAdapter(queue.queue, {
description: queue.description,
prefix: queue.prefix
});

//adapter.setFormatter('name', job => `#Queue1 - ${job.name}`);

return adapter;
});

createBullBoard({
queues: queueAdapters,
serverAdapter,
options: {
uiConfig: {
boardTitle: 'Bull Board',
boardLogo: { path: '/static/logo.png', width: '28px', height: '28px' },
favIcon: { default: '/static/favicon/android-chrome-512x512.png', alternative: 'static/favicon/favicon-32x32.png' },
miscLinks: [{ text: 'Dashboard', url: '/admin' }]
}
}
});

serverAdapter.setBasePath('/admin/bull-board');
await server.register(serverAdapter.registerPlugin(), {
routes: { prefix: '/admin/bull-board' }
});
}

module.exports = init;
61 changes: 0 additions & 61 deletions lib/arena-express.js

This file was deleted.

59 changes: 0 additions & 59 deletions lib/routes-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,65 +954,6 @@ function applyRoutes(server, call) {
}
});

server.route({
method: 'GET',
path: '/admin/arena',
async handler(request, h) {
return h.view(
'arena/index',
{
pageTitle: 'Arena',
menuTools: true,
menuToolsArena: true,
iframePage: true
},
{
layout: 'app'
}
);
}
});

server.route({
method: 'GET',
path: '/admin/arena/queue/{queue}',
async handler(request, h) {
return h.view(
'arena/index',
{
pageTitle: 'Arena',
menuTools: true,
menuToolsArena: true,
iframePage: true,

queue: request.params.queue
},
{
layout: 'app'
}
);
},

options: {
validate: {
options: {
stripUnknown: true,
abortEarly: false,
convert: true
},

async failAction(request, h, err) {
request.logger.error({ msg: 'Failed to validate queue argument', err });
return h.redirect('/admin').takeover();
},

params: Joi.object({
queue: Joi.string().empty('').valid('submit', 'notify', 'documents').label('Queue').required()
})
}
}
});

server.route({
method: 'GET',
path: '/admin/legal',
Expand Down
Loading

0 comments on commit e6762b9

Please sign in to comment.