title: Restarting child process
body: <p>I have a main process that spawns child processes. When the child process is killed, it is restarted, but when it is killed again, it will not restart.</p>
  
  <p>test.js</p>
  
  <pre><code>const fork = require('child_process').fork;
  const path = require('path');
  const test = path.resolve('test2.js');
  let test_child = fork(test);
  
  test_child.on("close", () =&gt; {
      console.log("child gone");
      setTimeout(() =&gt; {
          test_child = fork(test);
      }, 2500)
  });
  </code></pre>
  
  <p>test2.js</p>
  
  <pre><code>setInterval(() =&gt; {
      console.log("test")
  }, 250);
  </code></pre>
  
  <p>I want the main process (test.js), to continually start up (test2.js) if it ever crashes or stops for some reason.</p>