upbeat
Version:
Fast health and performance monitoring with process handling
44 lines (34 loc) • 1.01 kB
text/troff
var OK = 200;
var NOTOK = 500;
/*
* GET home page.
*/
module.exports =
app.get('/',
res.render('index', { hasService: upbeat.services.length, services: upbeat.services, hasProcess: upbeat.processes.length, processes: upbeat.processes })
});
app.get('/index.json',
var payload = services.map(
});
require('./services')(app, upbeat);
app.get('/health',
var ret = {};
var total = 0;
var count = 0;
foreach (var service in upbeat.servicesArray) {
total++;
if (service.isUp()) count++;
}
var healthy = total == count;
var ratio = count + "/" + total;
if (!healthy) {
res.send("Unhealthy (" + ratio + ")", NOTOK);
} else {
res.send("Healthy (" + ratio + ")", OK);
}
});
app.get('/processes/:name',
var process = upbeat.processes[req.params.name];
res.render('process', { process: process });
});
};