-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathserver.js
41 lines (32 loc) · 972 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
34
35
36
37
38
39
40
41
var express = require('express');
var app = express();
var compress = require('compression');
var fs = require('fs');
var exec = require('child_process').exec
var port = parseInt(process.env.PORT) || 80;
var http = require('http');
var checkfn = 'dbinitcheck.txt';
app.use(compress());
if(!fs.existsSync(checkfn)) {
exec('node dbinit_remote.js', function(err) {
if(!err) {
fs.writeFileSync(checkfn, 'true');
return;
}
console.log(err);
});
}
app.get('/', function(req, res) {
fs.readFile('./domain/index.html', function (err, data) {
res.send( data.toString()
.replace(/\{SITE_NAME\}/g, process.env.SITE_NAME || '')
.replace(/\{MSA_URL\}/g , process.env.MSA_URL || '')
);
});
});
app.get('/health/', function(req, res) {
res.json({health: "ok"});
});
app.use(express.static(__dirname + '/'));
app.listen(port);
console.log('Listening on port ' + port);