diff --git a/Dockerfile b/Dockerfile index 8f4c608..50fbcdc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:12-alpine +FROM node:14.15-alpine WORKDIR /usr/app @@ -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 diff --git a/README.md b/README.md index 9d600c3..18d1300 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/index.js b/index.js index 117a1f3..861b898 100644 --- a/index.js +++ b/index.js @@ -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'); @@ -9,6 +10,7 @@ const { REDIS_PASSWORD, REDIS_USE_TLS, BULL_PREFIX = 'bull', + BULL_VERSION = 'BULLMQ', PORT = 3000, BASE_PATH = '/' } = process.env; @@ -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); });