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 RUN yarn install && yarn cache clean -f
ENTRYPOINT ["yarn"]

View File

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

View File

@ -7,7 +7,8 @@
"txWorker": "node txWorker.js", "txWorker": "node txWorker.js",
"healthWorker": "node healthWorker.js", "healthWorker": "node healthWorker.js",
"dev:server": "nodemon --watch './src/**/*.ts' --exec ts-node src/app/index.ts", "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", "build": "tsc",
"eslint": "eslint --ext .ts --ignore-path .gitignore .", "eslint": "eslint --ext .ts --ignore-path .gitignore .",
"prettier:check": "npx prettier --check . --config .prettierrc", "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 relayerVersion = require(`${isProduction ? '.' : '..'}/package.json`).version;
export const netId = <availableIds>Number(process.env.NET_ID || 1); 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 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 mainnetRpcUrl = process.env.ORACLE_RPC_URL || 'https://mainnet.infura.io/';
export const offchainOracleAddress = '0x07D91f5fb9Bf7798734C3f606dB065549F6893bb'; export const offchainOracleAddress = '0x07D91f5fb9Bf7798734C3f606dB065549F6893bb';
export const multiCallAddress = '0xda3c19c6fe954576707fa24695efb830d9cca1ca'; export const multiCallAddress = '0xda3c19c6fe954576707fa24695efb830d9cca1ca';

View File

@ -3,13 +3,14 @@ import { Processor } from 'bullmq';
export const healthProcessor: Processor = async () => { export const healthProcessor: Processor = async () => {
const healthService = getHealthService(); const healthService = getHealthService();
try { try {
await healthService.check(); const status = await healthService.check();
await healthService.clearErrorCodes(); await healthService.clearErrorCodes();
await healthService.setStatus({ status: true, error: '' }); await healthService.setStatus({ status: true, error: '' });
return status;
} catch (e) { } catch (e) {
await healthService.saveError(e); await healthService.saveError(e);
await healthService.setStatus({ status: false, error: e.message }); 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); console.log('price worker', price.queue.name);
price.worker.on('active', () => console.log('worker active')); price.worker.on('active', () => console.log('worker active'));
price.worker.on('completed', async (job, result) => { 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)); price.worker.on('failed', (job, error) => healthService.saveError(error));
}; };
@ -31,12 +31,14 @@ export const relayerWorker = async () => {
}; };
export const healthWorker = async () => { export const healthWorker = async () => {
console.log('health worker starting');
await configService.init(); await configService.init();
const health = new HealthQueueHelper(); const health = new HealthQueueHelper();
health.scheduler.on('stalled', (jobId, prev) => console.log({ jobId, prev }));
console.log(health.queue.name, 'worker started'); console.log(health.queue.name, 'worker started');
health.scheduler.on('stalled', (jobId, prev) => console.log({ jobId, prev }));
health.worker.on('completed', (job, result) => { 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) => { health.worker.on('failed', (job, error) => {
console.log(error); console.log(error);

View File

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

View File

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