Notorious Penguin Magicians

    @fibjs/cluster-server

    3.0.0 • Public • Published

    @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

    Install

    npm i @fibjs/cluster-server

    DownloadsWeekly Downloads

    33

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    10.5 kB

    Total Files

    11

    Last publish

    Collaborators

    • ngot
    • ngot-fibjs