updates and fixes 2

This commit is contained in:
smart_ex 2022-06-30 19:25:36 +10:00
parent b48a44ae4e
commit 1532bfc4db
8 changed files with 31 additions and 18 deletions

View File

@ -25,4 +25,3 @@ COPY --from=dev /usr/app/yarn.lock /app/
RUN yarn install && yarn cache clean -f
ENTRYPOINT ["yarn"]

View File

@ -1,35 +1,37 @@
version: '3'
version: '3.7'
services:
server:
image: tornadocash/relayer:v5.0.0
restart: always
command: 'server'
command: 'node app/index.js'
env_file: .env
build:
context: .
dockerfile: Dockerfile
ports:
- 8000:8000
depends_on: [redis]
depends_on: [ redis ]
txWorker:
image: tornadocash/relayer:v5.0.0
restart: always
command: 'txWorker'
restart: unless-stopped
command: 'node txWorker.js'
env_file: .env
depends_on: [redis]
depends_on: [ redis ]
healthWorker:
image: tornadocash/relayer:v5.0.0
restart: always
command: 'healthWorker'
restart: unless-stopped
command: 'node healthWorker.js'
env_file: .env
depends_on: [redis]
depends_on: [ redis ]
redis:
image: redis
restart: always
restart: unless-stopped
ports:
- 6379:6379
environment:
- REDIS_APPENDONLY=yes
- REDIS_APPENDFSYNC=always
@ -38,3 +40,8 @@ services:
volumes:
redis:
#networks:
# default:
# external: true
# name: frontend_default

View File

@ -7,7 +7,8 @@
"txWorker": "node txWorker.js",
"healthWorker": "node healthWorker.js",
"dev:server": "nodemon --watch './src/**/*.ts' --exec ts-node src/app/index.ts",
"dev:worker": "nodemon --watch './src/**/*.ts' --exec ts-node src/worker.ts",
"dev:healthWorker": "nodemon --watch './src/**/*.ts' --exec ts-node src/healthWorker.ts",
"dev:txWorker": "nodemon --watch './src/**/*.ts' --exec ts-node src/txWorker.ts",
"build": "tsc",
"eslint": "eslint --ext .ts --ignore-path .gitignore .",
"prettier:check": "npx prettier --check . --config .prettierrc",

View File

@ -6,7 +6,7 @@ const isProduction = process.env.NODE_ENV === 'production';
export const relayerVersion = require(`${isProduction ? '.' : '..'}/package.json`).version;
export const netId = <availableIds>Number(process.env.NET_ID || 1);
export const redisUrl = process.env.REDIS_URL || 'redis://127.0.0.1:6379';
export const rpcUrl = process.env.RPC_URL;
export const rpcUrl = process.env.HTTP_RPC_URL;
export const mainnetRpcUrl = process.env.ORACLE_RPC_URL || 'https://mainnet.infura.io/';
export const offchainOracleAddress = '0x07D91f5fb9Bf7798734C3f606dB065549F6893bb';
export const multiCallAddress = '0xda3c19c6fe954576707fa24695efb830d9cca1ca';

View File

@ -3,13 +3,14 @@ import { Processor } from 'bullmq';
export const healthProcessor: Processor = async () => {
const healthService = getHealthService();
try {
await healthService.check();
const status = await healthService.check();
await healthService.clearErrorCodes();
await healthService.setStatus({ status: true, error: '' });
return status;
} catch (e) {
await healthService.saveError(e);
await healthService.setStatus({ status: false, error: e.message });
return { error: e.message };
}
};

View File

@ -11,7 +11,7 @@ export const priceWorker = async () => {
console.log('price worker', price.queue.name);
price.worker.on('active', () => console.log('worker active'));
price.worker.on('completed', async (job, result) => {
console.log(`Job ${job.id} completed with result: ${result}`);
console.log(`Job ${job.name} completed with result: `, result);
});
price.worker.on('failed', (job, error) => healthService.saveError(error));
};
@ -31,12 +31,14 @@ export const relayerWorker = async () => {
};
export const healthWorker = async () => {
console.log('health worker starting');
await configService.init();
const health = new HealthQueueHelper();
health.scheduler.on('stalled', (jobId, prev) => console.log({ jobId, prev }));
console.log(health.queue.name, 'worker started');
health.scheduler.on('stalled', (jobId, prev) => console.log({ jobId, prev }));
health.worker.on('completed', (job, result) => {
console.log(`Job ${job.id} completed with result: `, result);
console.log(`Job ${job.name} completed with result: `, result);
});
health.worker.on('failed', (job, error) => {
console.log(error);

View File

@ -100,6 +100,7 @@ export class ConfigService {
}
async checkNetwork() {
console.log('Checking network...');
await this.provider.getNetwork();
if (this.isLightMode) {
await this.mainnentProvider.getNetwork();
@ -110,6 +111,7 @@ export class ConfigService {
try {
if (this.isInit) return;
await this.checkNetwork();
console.log('Initializing...');
this._tokenAddress = await resolve(torn.torn.address);
this._tokenContract = await getTornTokenContract(this._tokenAddress);
if (this.isLightMode) {

View File

@ -127,6 +127,7 @@ export class HealthService {
if (tornStatus.level === 'CRITICAL') {
throw new RelayerError(tornStatus.message, 'INSUFFICIENT_TORN_BALANCE');
}
return { mainStatus, tornStatus };
}
}