4.6.4 • Published 1 year ago
@skyfury/egg-bull-board v4.6.4
egg bull board
Install
npm install @skyfury/egg-bull-board -S
bull-board
Use
'use strict';
const Bull = require('bull')
const { EggAdapter } = require('@skyfury/egg-bull-board')
const { createBullBoard } = require('@bull-board/api');
const { BullAdapter } = require('@bull-board/api/bullAdapter');
const redisOptions = {
port: 6379,
host: 'localhost',
password: '',
tls: false,
};
const createQueue = (name) => new Bull(name, { connection: redisOptions });
/**
* @param {Egg.Application} app - egg application
*/
module.exports = app => {
const { router, controller } = app;
const bullQueue = createQueue('bull');
const serverAdapter = new EggAdapter();
createBullBoard({
queues: [new BullAdapter(bullQueue)],
serverAdapter,
});
serverAdapter.setBasePath('/ui');
app.use(serverAdapter.registerPlugin());
router.get('/add', async (ctx) => {
const opts = ctx.query.opts || {};
if (opts.delay) {
opts.delay = +opts.delay * 1000; // delay must be a number
}
await bullQueue.add('Add', { title: ctx.query.title }, opts);
ctx.body = {
ok: true,
};
});
console.log(`For the UI of instance1, open http://localhost:${app.config.cluster.listen.port}/ui`);
console.log('Make sure Redis is running on port 6379 by default');
console.log('To populate the queue, run:');
console.log(` curl http://localhost:${app.config.cluster.listen.port}/add?title=Example`);
console.log('To populate the queue with custom options (opts), run:');
console.log(` curl http://localhost:${app.config.cluster.listen.port}/add?title=Test&opts[delay]=9`);
};
4.6.4
1 year ago
4.2.2
2 years ago
4.3.0
2 years ago
4.1.2
2 years ago
4.0.0
2 years ago
4.1.1
2 years ago
3.11.0
2 years ago
3.11.1
2 years ago
3.10.4
2 years ago
3.10.7
2 years ago
3.10.2
2 years ago
3.10.1
2 years ago
3.10.0
2 years ago
1.1.2
2 years ago
3.9.3
2 years ago
3.9.2
2 years ago
3.9.1
2 years ago
3.9.0
2 years ago
3.9.4
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago