0

I want my processes to remain their existence if Node.js application is killed or restarted but they are killed after my application restarts itself. I've created the code below thanks to this article: Check here but it didn't work for me. I am using Linux btw.

    const child = spawn(`${a}`, ['-mount', `${b}`, '-device', `${c}`], { detached: true, stdio: 'ignore' });
    child.unref();
  • You code should work, try it with `'sleep', ['60']` and you should see a sleep process running. The issue might be related to the specific process you are launching and using `ignore` which attaches `/dev/null` to sdtin/out/err. – Matt Jan 12 '22 at 09:24
  • I think I just found out that the problem is about the nodemon. I think nodemon relaunches itself as a daemon process, which will be the parent of node process and my child process will be the child of the node process, and if I kill or restart this process my linked child process kills itself too. The key concept here is the "daemon process" I think. Btw I just assumed these because I tried my code by running only "node index.js" and it worked like a charm. If you guys know the main problem behind (or the feature) nodemon, please explain. – Batuhan Isildak Jan 12 '22 at 12:31

0 Answers0