fix database connection leak, disable default prometheus metrics
This commit is contained in:
parent
3a1f54eb8e
commit
473178e810
@ -12,5 +12,8 @@
|
||||
"express": "^4.17.1",
|
||||
"pg": "^8.5.1",
|
||||
"prom-client": "^12.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node ./src/index.js"
|
||||
}
|
||||
}
|
||||
|
12
src/index.js
12
src/index.js
@ -24,14 +24,21 @@ const startServer = () => {
|
||||
server.listen(serverPort, serverHost, () => console.log(`Http server running on port ${serverHost}:${serverPort}`));
|
||||
}
|
||||
|
||||
const run = async () => {
|
||||
let dbStateDiff;
|
||||
|
||||
const connectToDB = () => {
|
||||
const statediffUser = process.env.STATEDIFF_PG_USER;
|
||||
const statediffPassword = process.env.STATEDIFF_PG_PASSWORD;
|
||||
const statediffDB = process.env.STATEDIFF_PG_DATABASE;
|
||||
const statediffHost = process.env.STATEDIFF_PG_HOST;
|
||||
const statediffPort = process.env.STATEDIFF_PG_PORT;
|
||||
|
||||
const dbStateDiff = new DB('statediff', statediffUser, statediffPassword, statediffDB, statediffHost, statediffPort)
|
||||
dbStateDiff = new DB('statediff', statediffUser, statediffPassword, statediffDB, statediffHost, statediffPort)
|
||||
}
|
||||
|
||||
const run = async () => {
|
||||
|
||||
// statediff database
|
||||
const dbStateDiffBlockNumber = dbStateDiff.getBlockNumber();
|
||||
|
||||
// Etherscan
|
||||
@ -71,6 +78,7 @@ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||
|
||||
const main = async () => {
|
||||
startServer();
|
||||
connectToDB();
|
||||
|
||||
let lock = false;
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
const client = require('prom-client');
|
||||
|
||||
const collectDefaultMetrics = client.collectDefaultMetrics;
|
||||
const Registry = client.Registry;
|
||||
const register = new Registry();
|
||||
const prefix = 'eth_state_metrics_';
|
||||
collectDefaultMetrics({ register });
|
||||
|
||||
const etherscanGauge = new client.Gauge({ name: `${prefix}etherscan`, help: 'Etherscan Block Number', registers: [register]});
|
||||
const statediffDBGauge = new client.Gauge({ name: `${prefix}statediff_db`, help: 'Statediff DB Block Number', registers: [register]});
|
||||
|
Loading…
Reference in New Issue
Block a user