From 2259d7d15fac910f6b56a4f4bb8b37c7223784ed Mon Sep 17 00:00:00 2001 From: Danil Kovtonyuk Date: Wed, 27 Oct 2021 23:17:35 +1000 Subject: [PATCH] fix: redis url --- example.env | 5 +++++ package.json | 4 ++-- src/config/bull.config.ts | 6 +----- src/modules/queue/queue.module.ts | 9 +++++++-- src/modules/queue/transaction.processor.ts | 2 ++ 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/example.env b/example.env index 016c4c6..7810ef5 100644 --- a/example.env +++ b/example.env @@ -5,6 +5,11 @@ LETSENCRYPT_HOST= # server settings PORT=8000 +# for production +REDIS_URL=redis://redis/0 +# for development +# REDIS_URL=localhost + CHAIN_ID=100 REWARD_ADDRESS= diff --git a/package.json b/package.json index 7e2c4a5..2a90a21 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "build": "nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "start": "nest start", - "start:dev": "NODE_ENV=development nest start --watch", - "start:debug": "NODE_ENV=development nest start --debug --watch", + "start:dev": "nest start --watch", + "start:debug": "nest start --debug --watch", "start:prod": "yarn prebuild; yarn build; node dist/src/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "test": "jest", diff --git a/src/config/bull.config.ts b/src/config/bull.config.ts index 2c27fa9..ef03878 100644 --- a/src/config/bull.config.ts +++ b/src/config/bull.config.ts @@ -1,11 +1,7 @@ import { registerAs } from '@nestjs/config'; export default registerAs('bull', () => ({ - name: 'transaction', - redis: { - host: process.env.NODE_ENV === 'development' ? 'localhost' : 'redis', - port: 6379, - }, + redis: process.env.REDIS_URL || 'localhost', settings: { lockDuration: 300000, lockRenewTime: 30000, diff --git a/src/modules/queue/queue.module.ts b/src/modules/queue/queue.module.ts index fee502a..73bf64e 100644 --- a/src/modules/queue/queue.module.ts +++ b/src/modules/queue/queue.module.ts @@ -1,5 +1,5 @@ -import { BullModule } from '@nestjs/bull'; import { Module } from '@nestjs/common'; +import { BullModule } from '@nestjs/bull'; import { GasPriceService, ProviderService, OffchainPriceService } from '@/services'; @@ -8,7 +8,12 @@ import { TransactionProcessor } from './transaction.processor'; import bullConfig from '@/config/bull.config'; @Module({ - imports: [BullModule.registerQueue(bullConfig())], + imports: [ + BullModule.registerQueueAsync({ + name: 'transaction', + useFactory: bullConfig, + }), + ], providers: [GasPriceService, ProviderService, TransactionProcessor, OffchainPriceService], exports: [BullModule], }) diff --git a/src/modules/queue/transaction.processor.ts b/src/modules/queue/transaction.processor.ts index d4d2bac..73b9f28 100644 --- a/src/modules/queue/transaction.processor.ts +++ b/src/modules/queue/transaction.processor.ts @@ -157,6 +157,8 @@ export class TransactionProcessor extends BaseProcessor { throw new Error(`Revert by smart contract: ${error}`); } + console.log('handleError:', message); + throw new Error('Relayer did not send your transaction. Please choose a different relayer.'); } }