From f960a59ab9134e45397a63546a6b490da8bc6c90 Mon Sep 17 00:00:00 2001 From: Abdul Ahad Date: Wed, 1 Feb 2023 19:55:24 +0500 Subject: [PATCH] redis host and port issue --- .env.example | 4 +++- README.md | 2 ++ src/services/job.service.ts | 7 ++++++- src/worker.ts | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 2c431d5..4dda265 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,6 @@ PORT=3000 MONGODB_URL=mongodb://127.0.0.1:27017/multiswap-node QUEUE=Transaction -GATEWAY_BACKEND_URL= \ No newline at end of file +GATEWAY_BACKEND_URL=https://api-leaderboard.dev.svcs.ferrumnetwork.io +REDIS_HOST=127.0.0.1 +REDIS_PORT=6379 \ No newline at end of file diff --git a/README.md b/README.md index ed70598..ab75d88 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Redis Version `v7.0.8` Run the Redis Server in your machine by using `redis-server` command +Run this command `cp .env.example .env` to create .env file + Run `yarn` OR `yarn install` at the root of the repo Run `yarn dev` to run Server diff --git a/src/services/job.service.ts b/src/services/job.service.ts index 5ee4120..1ceffd4 100644 --- a/src/services/job.service.ts +++ b/src/services/job.service.ts @@ -3,7 +3,12 @@ import { JobRequestBody } from '../interfaces'; import dotenv from 'dotenv'; dotenv.config(); -const queue = new Queue(process.env.QUEUE as string); +const queue = new Queue(process.env.QUEUE as string, { + connection: { + host: process.env.REDIS_HOST as string, + port: Number(process.env.REDIS_PORT) as number, + }, +}); export const addJobs = async (jobBody: JobRequestBody): Promise => { const job = await queue.add(jobBody.name, jobBody); diff --git a/src/worker.ts b/src/worker.ts index 12b6959..cf61f4e 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -5,6 +5,12 @@ const worker = new Worker( process.env.QUEUE as string, async job => await web3Service.getTransactionReceipt(job.data.txId, job.data.rpcURL), + { + connection: { + host: process.env.REDIS_HOST as string, + port: Number(process.env.REDIS_PORT) as number, + }, + }, ); worker.on('completed', async job => { console.info(`${job.id} has completed!`);