-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (30 loc) · 1001 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const express = require('express');
const exec = require('./services/exec');
const getActualBlocksCount = require('./services/getActualBlocksCount');
const getDaemonUptime = require('./services/getDaemonUptime');
const app = express();
const PORT = process.env.PORT || 3000;
const fetchInfo = cmd => exec(`${process.env.PIVXCLI} ${cmd}`);
app.set('views', './views');
app.enable('view cache');
app.set('view engine', 'pug');
app.get('/', function (req, res) {
Promise.all([
getDaemonUptime(),
fetchInfo('masternode debug'),
fetchInfo('getbalance'),
fetchInfo('getblockcount')
])
.then(([daemonProcessUptime, debug, balance, blockCount]) => (
res.render('status', {
daemonProcessUptime,
debug,
balance,
blockCount
})
)
)
});
app.listen(PORT, function () {
console.log(`Example app listening on port ${PORT}!`)
});