forked from karthik947/bullboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (37 loc) · 1.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const express = require("express");
const dotenv = require("dotenv");
const Queue = require("bull");
const { createBullBoard } = require("@bull-board/api");
const { BullAdapter } = require("@bull-board/api/bullAdapter");
const { ExpressAdapter } = require("@bull-board/express");
(async () => {
dotenv.config();
// Define the Redis connection options
const redisOptions = {
redis: {
host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT,
password: process.env.REDIS_PASSWORD, // if no password, omit this field
},
};
// Create a new queue with the Redis connection options
const queuesList = ["burger"];
const serverAdapter = new ExpressAdapter();
serverAdapter.setBasePath("/admin/queues");
const queues = queuesList
.map((qs) => new Queue(qs, redisOptions))
.map((q) => new BullAdapter(q));
const { addQueue, removeQueue, setQueues, replaceQueues } = createBullBoard({
queues,
serverAdapter: serverAdapter,
});
const app = express();
app.use("/admin/queues", serverAdapter.getRouter());
// other configurations of your server
const { PORT } = process.env;
app.listen(PORT, () => {
console.info(`Running on ${PORT}...`);
console.info(`For the UI, open http://localhost:${PORT}/admin/queues`);
console.info("Make sure Redis is running on port 6379 by default");
});
})();