typescript导入cluster与hapi实现多核多线程http服务器代码
代码语言:typescript
代码描述:typescript导入cluster与hapi实现多核多线程http服务器代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
import * as cluster from 'cluster'; import { cpus } from 'os'; import * as Hapi from 'hapi'; const numCPUs = cpus().length; if (cluster.isMaster) { for (var i = 0; i < numCPUs; i++) { cluster.fork(); } cluster.on('exit', (worker, code, signal) => { console.log(`worker ${worker.process.pid} died`); }); } else { const server = new Ha.........完整代码请登录后点击上方下载按钮下载查看
网友评论0