title: Pass app object from Parent to Node child process
body: <p>I am working on creating a child process. As a part of that I need to pass the app object from parent to child process.</p>
  
  <p>parent.js</p>
  
  <pre><code>module.exports = function (app) {
    // app object is available here. Need to pass this to child
    const path = require("path");
    const cp = require('child_process');
    let child = cp.fork(__dirname + '../../worker/worker.js');
    child.on('message', (app) =&gt; {
          console.log('Message from child', app);
    });
  
    child.send({ 'app': app });
  };
  </code></pre>
  
  <p>worker.js</p>
  
  <pre><code>process.on('message', (app) =&gt; {
      console.log('Message from parent:', app);
  });
  </code></pre>
  
  <p>Output I am getting now is : Message from parent: {}</p>
  
  <p>Can you tell me spawn or fork I have to use. Any help would be really appreciated</p>