title: How to achieve 100 % uptime for the server using cluster for handling the load and express for server configration
body: <p>I want to create a server using cluster.
  I have quadcore(4 cpu).</p>
  
  <p>I want to make one as master
  for switching the request / response among three worker server.
  When a worker throws an exception or dies it should restart
  meanwhile other worker will be still running and when the worker will be restarting itself master should not route any request to it.</p>
  
  <blockquote>
    <p>So that 100 % uptime can be achieved for the server.</p>
  </blockquote>
  
  <p>I had tried following but it not fulfilling my requirement</p>
  
  <pre><code>const cluster = require('cluster');
  const numCPUs = require('os').cpus().length;
  
  if (cluster.isMaster) {
      // Fork workers.
      for (var i = 0; i &lt; numCPUs; i++) {
          cluster.fork();
      }
  
      cluster.on('exit', (worker, code, signal) =&gt; {
          console.log(`worker ${worker.process.pid} died`);
      });
  } else {
      var express = require(NODE_PATH + 'express'),
          app = express();
  
      var addApiList = require("./api_routes/apiList");
      addApiList(app);
  
      app.listen(8085, function() {
          console.log('listening on port : ' + 8085);
      });
  
  }
  </code></pre>