Skip to content

Commit 0afdf1a

Browse files
committed
add worker
1 parent 7b06521 commit 0afdf1a

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

apps/worker/src/index.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createBullBoard } from '@bull-board/api';
22
import { BullMQAdapter } from '@bull-board/api/bullMQAdapter';
33
import { ExpressAdapter } from '@bull-board/express';
4+
import type { WorkerOptions } from 'bullmq';
45
import { Worker } from 'bullmq';
56
import express from 'express';
67

@@ -10,20 +11,21 @@ import { cronQueue } from '@mixan/queue/src/queues';
1011
import { cronJob } from './jobs/cron';
1112
import { eventsJob } from './jobs/events';
1213

13-
const PORT = process.env.PORT || 3000;
14+
const PORT = parseInt(process.env.WORKER_PORT || '3000', 10);
1415
const serverAdapter = new ExpressAdapter();
1516
serverAdapter.setBasePath('/');
1617
const app = express();
1718

18-
new Worker(eventsQueue.name, eventsJob, {
19+
const workerOptions: WorkerOptions = {
1920
connection,
20-
});
21-
22-
new Worker(cronQueue.name, cronJob, {
23-
connection,
24-
});
21+
concurrency: parseInt(process.env.CONCURRENCY || '1', 10),
22+
};
2523

2624
async function start() {
25+
new Worker(eventsQueue.name, eventsJob, workerOptions);
26+
27+
new Worker(cronQueue.name, cronJob, workerOptions);
28+
2729
createBullBoard({
2830
queues: [new BullMQAdapter(eventsQueue), new BullMQAdapter(cronQueue)],
2931
serverAdapter: serverAdapter,
@@ -53,9 +55,6 @@ async function start() {
5355
},
5456
}
5557
);
56-
// if (!repeatableJobs.find((job) => job.name === 'salt')) {
57-
// console.log('Add salt job to queue');
58-
// }
5958
}
6059

6160
start();

captain-definition-worker

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"schemaVersion": 2,
3+
"dockerfilePath": "./apps/worker/Dockerfile"
4+
}

0 commit comments

Comments
 (0)