Muthithreaded webapp

This commit is contained in:
Sam Calder-Mason 2018-03-08 17:57:30 +11:00
parent 8c8dd605fa
commit 53a79c52e7
1 changed files with 16 additions and 17 deletions

View File

@ -193,24 +193,23 @@ loadFromFile((result) => {
const http = require('http');
const numCPUs = require('os').cpus().length;
// if (cluster.isMaster) {
// // Fork workers.
// setInterval(() => {
// if (cluster.isMaster) {
// killOldInvites()
// }
// }, 3600000)
// for (let i = 0; i < numCPUs; i++) {
// cluster.fork();
// }
if (cluster.isMaster) {
// Fork workers.
setInterval(() => {
if (cluster.isMaster) {
killOldInvites()
}
}, 3600000)
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}
// cluster.on('exit', (thread, code, signal) => {
// console.log(`thread ${thread.process.pid} died`, code, signal)
// });
// } else {
// rootserver.listen(PORT)
// }
cluster.on('exit', (thread, code, signal) => {
console.log(`thread ${thread.process.pid} died`, code, signal)
});
} else {
rootserver.listen(PORT)
}
})
console.log('SyncLounge WebApp successfully started on port ' + PORT)