Is it possible to restart a running single-threaded node process entirely from within itself?
I imagine the steps to take for a server would be something like this:
child_process.forkor child_process.spawn, handing over process.argv to the child.Could this work or am I totally wrong?
This is possible, but generally people just use existing solutions that start a single master process and N server processes. Then when a server process dies or stops, it just starts a new one. One example is pm2.
That said, your example sounds correct to me as long as you use the detached: true argument for .spawn