title: How to retain global variable value
body: <p>I am using global variable arr [] in one file called File1.js. When I run the file in node, its working.But using Cluster module in node its not working. Any help on this will be really helpful.</p>
  
  <pre><code>//Cluster.js
  var cluster = require('cluster');
  var workers = process.env.WORKERS || require('os').cpus().length;
  
  if (cluster.isMaster) {
      winston.log("info", "start cluster with %s workers" + workers);
      // Create a worker for each CPU
      for (var i = 0; i &lt; workers; i++) {
          var options = { exec: "File1.js" };
          cluster.setupMaster(options);
          var worker = cluster.fork().process;
          winston.log("info", "worker %s started." + worker.pid);
          worker.on('death', function (worker) {
              winston.log("debug", "worker " + worker.pid + " died. restart...");
              cluster.fork();
          });
          worker.on('message', function (message) {
              // error in message.err
              winston.log("error", "Error Message: " + message.err);
          });
      }
  }
  
  if (cluster.isWorker) {
      process.on('uncaughtException', function (err) {
          // tell the master there is an error
          //process.send({ err: err });
          winston.log("error", "Error Message: " + err.stack);
      });
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I will be using node Cluster.js which will call <a href="https://stackoverflow.com/questions/24074604/how-to-declare-and-access-global-variable?noredirect=1#comment37126820_24074604">File1.js</a></p>