-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
32 lines (25 loc) · 878 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
require('./init');
const cluster = require('cluster');
const os = require('os');
const configs = require("./config/app.config");
const PORT = configs.PORT;
const makeApplication = require('./app');
const server = makeApplication();
server.listen(PORT, () => {
console.log(`ProcessId: ${process.pid}. Running on http://0.0.0.0:${PORT}/`);
});
// TODO: scale express + socket.io using redis
// if (cluster.isMaster && configs.APP_MODE === "production" && false) {
// console.log(`Running on: http://localhost:${PORT}`);
// for (let cpu of os.cpus()) {
// cluster.fork();
// }
// cluster.on('exit', (worker, code, signal) => {
// console.log(`Worker ${worker.process.pid} died (${signal}. Restarting...)`);
// cluster.fork();
// });
// } else {
// server.listen(PORT, () => {
// console.log(`Worker ${process.pid} is running...`);
// });
// }