Skip to content

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

License

Notifications You must be signed in to change notification settings

fibjs-modules/cluster-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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

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

Usage

server.js :

const Cluster = require('@fibjs/cluster-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 :

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

then you can start server:

  fibjs server.js

worker.js

We can export any handler described at http://fibjs.org/docs/manual/module/ifs/mq.md.html#Handler.

Questions & Suggestions

Please open an issue here.

License

MIT

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published