-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (39 loc) · 1.42 KB
/
app.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
42
43
44
45
46
47
48
49
require('dotenv').config()
const Path = require('path');
const Express = require('express');
const favicon = require('serve-favicon');
const app = Express();
const port = 8000;
app.use(Express.static(Path.join(__dirname, 'public')));
app.use(favicon(Path.join(__dirname, 'public', 'favicon.png')))
app.use(Express.urlencoded({ extended: true }));
app.set('view engine', 'ejs');
app.set('views', Path.join(__dirname, 'views'));
const SERVICE_TENANT = process.env.SERVICE_TENANT || 'aws';
const SERVICE_ENVIRONMENT = process.env.SERVICE_ENVIRONMENT || 'default';
const SERVICE_NAME = process.env.SERVICE_NAME || 'default';
const SERVICE_VERSION = process.env.SERVICE_VERSION || 'default';
const SERVICE_URL = process.env.SERVICE_URL || 'default';
app.get('*', (req, res) => {
res.render('index', {
SERVICE_TENANT: SERVICE_TENANT,
SERVICE_ENVIRONMENT: SERVICE_ENVIRONMENT,
SERVICE_NAME: SERVICE_NAME,
SERVICE_VERSION: SERVICE_VERSION,
SERVICE_URL: SERVICE_URL
});
});
const server = app.listen(port, () => {
console.log(`Demo app listening on port ${port}`);
});
process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown);
function shutdown() {
console.log('SIGINT signal received: closing HTTP server ...');
server.close(() => {
console.log('HTTP server closed!');
setTimeout(() => {
process.exit(0);
}, 3000);
});
}