show errors on status page
This commit is contained in:
parent
8868040882
commit
cfcf1c8677
@ -6,6 +6,7 @@ const { redis } = require('../modules/redis')
|
|||||||
async function status(req, res) {
|
async function status(req, res) {
|
||||||
const ethPrices = await redis.hgetall('prices')
|
const ethPrices = await redis.hgetall('prices')
|
||||||
const health = await redis.hgetall('health')
|
const health = await redis.hgetall('health')
|
||||||
|
const errors = await redis.zrevrange('errors', 0, -1)
|
||||||
|
|
||||||
const { waiting: currentQueue } = await queue.queue.getJobCounts()
|
const { waiting: currentQueue } = await queue.queue.getJobCounts()
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ async function status(req, res) {
|
|||||||
miningServiceFee,
|
miningServiceFee,
|
||||||
version,
|
version,
|
||||||
health,
|
health,
|
||||||
|
errors,
|
||||||
currentQueue,
|
currentQueue,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,6 @@ async function main() {
|
|||||||
try {
|
try {
|
||||||
const { address } = web3.eth.accounts.privateKeyToAccount(privateKey)
|
const { address } = web3.eth.accounts.privateKeyToAccount(privateKey)
|
||||||
const balance = await web3.eth.getBalance(address)
|
const balance = await web3.eth.getBalance(address)
|
||||||
|
|
||||||
const errors = await redis.zrevrange('errors', 0, -1)
|
|
||||||
if (errors.length > 3) {
|
|
||||||
console.log({ errors })
|
|
||||||
throw new Error('Too many errors on relayer')
|
|
||||||
}
|
|
||||||
if (toBN(balance).lt(toBN(minimumBalance))) {
|
if (toBN(balance).lt(toBN(minimumBalance))) {
|
||||||
throw new RelayerError(`Not enough balance, less than ${fromWei(minimumBalance)} ETH`, 1)
|
throw new RelayerError(`Not enough balance, less than ${fromWei(minimumBalance)} ETH`, 1)
|
||||||
}
|
}
|
||||||
@ -20,6 +14,7 @@ async function main() {
|
|||||||
await redis.hset('health', { status: true, error: '' })
|
await redis.hset('health', { status: true, error: '' })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('healthWatcher', e.message)
|
console.error('healthWatcher', e.message)
|
||||||
|
redis.zadd('errors', e.score || 0, e.message)
|
||||||
await redis.hset('health', { status: false, error: e.message })
|
await redis.hset('health', { status: false, error: e.message })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const { offchainOracleAddress } = require('./config')
|
const { offchainOracleAddress } = require('./config')
|
||||||
const { getArgsForOracle, setSafeInterval, toChecksumAddress, toBN } = require('./utils')
|
const { getArgsForOracle, setSafeInterval, toChecksumAddress, toBN, RelayerError } = require('./utils')
|
||||||
const { redis } = require('./modules/redis')
|
const { redis } = require('./modules/redis')
|
||||||
const web3 = require('./modules/web3')()
|
const web3 = require('./modules/web3')()
|
||||||
|
|
||||||
@ -21,17 +21,18 @@ async function main() {
|
|||||||
const numerator = toBN(oneUintAmount[i])
|
const numerator = toBN(oneUintAmount[i])
|
||||||
const denominator = toBN(10).pow(toBN(18)) // eth decimals
|
const denominator = toBN(10).pow(toBN(18)) // eth decimals
|
||||||
const priceFormatted = toBN(price).mul(numerator).div(denominator)
|
const priceFormatted = toBN(price).mul(numerator).div(denominator)
|
||||||
|
|
||||||
ethPrices[currencyLookup[tokenAddresses[i]]] = priceFormatted.toString()
|
ethPrices[currencyLookup[tokenAddresses[i]]] = priceFormatted.toString()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('cant get price of ', tokenAddresses[i])
|
console.error('cant get price of ', tokenAddresses[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!Object.values(ethPrices).length) {
|
||||||
|
throw new RelayerError('Can`t update prices', 1)
|
||||||
|
}
|
||||||
await redis.hmset('prices', ethPrices)
|
await redis.hmset('prices', ethPrices)
|
||||||
console.log('Wrote following prices to redis', ethPrices)
|
console.log('Wrote following prices to redis', ethPrices)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
redis.zadd('errors', new Date().getTime(), e.message)
|
redis.zadd('errors', e.score || 1, e.message)
|
||||||
console.error('priceWatcher error', e)
|
console.error('priceWatcher error', e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ async function init() {
|
|||||||
eventSubscription = contract.events.NewAccount({ fromBlock: toBlock + 1 }, processNewEvent)
|
eventSubscription = contract.events.NewAccount({ fromBlock: toBlock + 1 }, processNewEvent)
|
||||||
blockSubscription = web3.eth.subscribe('newBlockHeaders', processNewBlock)
|
blockSubscription = web3.eth.subscribe('newBlockHeaders', processNewBlock)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
redis.zadd('errors', new Date().getTime(), e.message)
|
redis.zadd('errors', 1, e.message)
|
||||||
console.error('error on init treeWatcher', e.message)
|
console.error('error on init treeWatcher', e.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,11 +106,7 @@ async function start() {
|
|||||||
queue.process(processJob)
|
queue.process(processJob)
|
||||||
console.log('Worker started')
|
console.log('Worker started')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof RelayerError) {
|
redis.zadd('errors', e.score || 1, e.message)
|
||||||
if (e.score > 0) redis.zadd('errors', e.score, e.message)
|
|
||||||
} else {
|
|
||||||
redis.zadd('errors', 1, e.message)
|
|
||||||
}
|
|
||||||
console.error('error on start worker', e.message)
|
console.error('error on start worker', e.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user