Is there any way to spawn a new independent process from the current running script?
I am trying to run a new script from an already running script. The new script should be independent of the one that called it.
Is there any way to spawn a new independent process from the current running script?
I am trying to run a new script from an already running script. The new script should be independent of the one that called it.
You can use the 'detached' option and the unref() method to make child process independent.
const spawn = require('child_process').spawn;
const child = spawn(process.argv[0], ['child_program.js'], {
detached: true,
stdio: ['ignore']
});
child.unref();
Ref: Node.js document