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