Skip to content

Commit

Permalink
Adoptation for v1.2.0, added option BULL_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
Deadly0 committed Jan 14, 2021
1 parent d659e7f commit 87adf04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12-alpine
FROM node:14.15-alpine

WORKDIR /usr/app

Expand All @@ -11,6 +11,7 @@ ENV REDIS_PORT 6379
ENV REDIS_USE_TLS false
ENV REDIS_PASSWORD ''
ENV BULL_PREFIX bull
ENV BULL_VERSION BULLMQ

RUN yarn install

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ see "Example with docker-compose" section for example with env parameters
* `REDIS_USE_TLS` - enable TLS true or false (false by default)
* `REDIS_PASSWORD` - password to connect to redis (no password by default)
* `BULL_PREFIX` - prefix to your bull queue name (bull by default)
* `BULL_VERSION` - version of bull lib to use 'BULLMQ' or 'BULL' ('BULLMQ' by default)
* `BASE_PATH` - basePath for bull board, e.g. '/bull-board' ('/' by default)

### Example with docker-compose
Expand Down
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const {setQueues, router} = require('bull-board');
const {router, setQueues, BullMQAdapter, BullAdapter} = require('bull-board')
const Queue = require('bull');
const bullmq = require('bullmq');
const express = require('express');
const redis = require('redis');

Expand All @@ -9,6 +10,7 @@ const {
REDIS_PASSWORD,
REDIS_USE_TLS,
BULL_PREFIX = 'bull',
BULL_VERSION = 'BULLMQ',
PORT = 3000,
BASE_PATH = '/'
} = process.env;
Expand All @@ -29,7 +31,15 @@ const basePath = BASE_PATH;

client.KEYS(`${prefix}:*`, (err, keys) => {
const uniqKeys = new Set(keys.map(key => key.replace(/^.+?:(.+?):.+?$/, '$1')));
const queueList = Array.from(uniqKeys).map((item) => new Queue(item, redisConfig));
const queueList = Array.from(uniqKeys).sort().map(
(item) => {
if (BULL_VERSION === 'BULLMQ') {
return new BullMQAdapter(new bullmq.Queue(item, {connection: redisConfig.redis}));
}

return new BullAdapter(new Queue(item, redisConfig));
}
);

setQueues(queueList);
});
Expand Down

0 comments on commit 87adf04

Please sign in to comment.