-
Notifications
You must be signed in to change notification settings - Fork 32
/
server.js
33 lines (27 loc) · 903 Bytes
/
server.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
var express = require('express');
var exec = require('child_process').exec;
var app = express();
// Return a 200 for kubernetes healthchecks
app.get('/healthz', function(req, res){
res.status(200).end();
});
app.get('/', function(req, res){
var poweredBy = process.env.POWERED_BY;
var release = process.env.WORKFLOW_RELEASE;
if (typeof(message) == "undefined") {
poweredBy = "Deis";
}
exec('hostname', function(error, stdout, stderr) {
container = "unknown";
// If exec was successful
if (error == null) {
container = stdout.trim();
}
res.send('Powered by ' + poweredBy + '\nRelease ' + release + ' on ' + container);
});
});
/* Use PORT environment variable if it exists */
var port = process.env.PORT || 5000;
server = app.listen(port, function () {
console.log('Server listening on port %d in %s mode', server.address().port, app.settings.env);
});