Skip to content

Commit

Permalink
Added tez balance monitoring for health check
Browse files Browse the repository at this point in the history
  • Loading branch information
John Newby committed Oct 21, 2022
1 parent cd57078 commit 59b76eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 11 additions & 1 deletion app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,18 @@ const main = async function() {
queue.save_state(ids, state).catch((err) => { console.error("Database error when setting", state, "on operation with ids:", JSON.stringify(ids)); });;
}

const health_check = async function() {
let tez_supply = await tezos.tz.getBalance(address);
tez_supply = tez_supply.shiftedBy(-6).toNumber();
if (tez_supply > config.warnBelowTez) {
await queue.kill_canaries(address);
} else {
console.warn(`Tez balance on account ${address} below warning threshold`);
}
};

const heartbeat = async function() {
await queue.kill_canaries(address);
await health_check();

let ops = await queue.checkout(address, ~~(config.batchSize/batch_divider) + 1);
if (ops.length == 0) {
Expand Down
11 changes: 6 additions & 5 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
"rpcUrl": "http://immensely.newby.org:8734/",
"pollingDelay": 10000,
"timeout": 300,
"warnBelowTez": 10.0,
"dbConnection": {
"user": "tezos",
"password": "tezos",
"host": "localhost",
"port": 5432,
"database": "tezos"
"password": "tezos",
"host": "localhost",
"port": 5432,
"database": "tezos"
},
"handlers": {
"nft": {
Expand All @@ -24,4 +25,4 @@
"args": {}
}
}
}
}

0 comments on commit 59b76eb

Please sign in to comment.