Start a multi-thread server to take advantage of multi-core systems.
$ npm i @fibjs/cluster-server --save
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
We can export any handler described at http://fibjs.org/docs/manual/module/ifs/mq.md.html#Handler.
Please open an issue here.