const http = require('http');
const express = require('express');
const app = express();
const setttings = require('./app/config/settings');
const environment = require('./app/config/environment');
// var SocketServer=require("./app/config/socket.server");
// const cluster = require('cluster');
// const numCPUs = require('os').cpus().length;
// all environments
environment(app);// 初始化环境
// 错误处理中间件应当在路由加载之后才能加载
// if (cluster.isMaster) {
//   console.log(`Master ${process.pid} is running`);
//
//   // Fork workers.
//   for (let i = 0; i < numCPUs; i++) {
//     cluster.fork();
//   }
//   cluster.on('exit', (worker, code, signal) => {
//     console.log(`worker ${worker.process.pid} died`);
//   });
// }else{
//   var server = http.createServer(app);
//   var socketServer = new SocketServer(server);
//   server.listen(setttings.port, function(){
//     console.log('Express server listening on port ' + app.get('port'));
//   });
// }
const server = http.createServer(app);
// var socketServer = new SocketServer(server);
server.listen(setttings.port, () => {
  console.log(`Express server listening on port ${app.get('port')}`);
});

