Awesome 社区模块

@fibjs/cluster-server

NPM version build status appveyor build status Test coverage David deps Known Vulnerabilities npm download

Start a multi-thread server to take advantage of multi-core systems.

Install

1
$ npm i @fibjs/cluster-server --save

Usage

server.js :

1 2 3 4 5 6 7 8 9 10 11
const Cluster = require('@fibjs/C-server'); const path = require('path'); const server = new Cluster({ port: 8000,// server port,default to 8000 worker: path.join(__dirname, 'worker.js'), // full path to worker numbers: 4,// default to cpu numbers }); server.run(); // start server asynchronously // server.close(); // close server

worker.js :

1 2 3
module.exports = req => { req.response.write('Hello, World!'); };

then you can start server:

1
fibjs server.js

Questions & Suggestions

Please open an issue here.

License

MIT