2018-01-04 20:19:10 +00:00
|
|
|
const env = require('./config/prod.env');
|
|
|
|
|
2018-01-07 16:22:04 +00:00
|
|
|
Object.keys(env).forEach((key) => {
|
2018-01-04 23:10:49 +00:00
|
|
|
if (!process.env[key]) {
|
2018-01-07 16:22:04 +00:00
|
|
|
process.env[key] = JSON.parse(env[key]);
|
2018-01-04 23:10:49 +00:00
|
|
|
}
|
|
|
|
});
|
2017-09-27 20:27:12 +00:00
|
|
|
|
2017-09-30 12:01:29 +00:00
|
|
|
const http = require('http');
|
|
|
|
const express = require('express');
|
|
|
|
|
|
|
|
const app = express();
|
2017-09-26 22:54:26 +00:00
|
|
|
|
2017-09-29 18:43:26 +00:00
|
|
|
require('./server')(app, process.env.SERVE_V4);
|
2017-09-26 22:54:26 +00:00
|
|
|
|
2018-01-19 23:32:14 +00:00
|
|
|
const port = parseInt(process.env.PORT || 8080, 10);
|
2017-09-30 12:01:29 +00:00
|
|
|
const httpServer = http.createServer(app);
|
|
|
|
httpServer.listen(port, null, () => {
|
|
|
|
console.log(`HTTP server started: http://localhost:${port}`);
|
2017-09-26 22:54:26 +00:00
|
|
|
});
|
2018-03-30 12:04:41 +00:00
|
|
|
|
|
|
|
// Handle graceful shutdown
|
|
|
|
process.on('SIGTERM', () => {
|
|
|
|
httpServer.close(() => {
|
|
|
|
process.exit(0);
|
|
|
|
});
|
|
|
|
});
|