Node.js: Reload whole program from inside

Is there a way to reload (restart) whole program in Node.js. I don't mean on file change, just using some command. By reloading, I mean the same as pressing ctrl c in console and relaunching the program.

The easy way is to run your program under a process supervisor such as pm2 or forever, then just terminate you program's own process from inside via process.exit().

If you want to do it without a parent supervisor, it's possible (I think) but tricky to get right. You'll need to look at process.execPath, process.execArgv, and process.argv and use either child_process.fork or one of the child_process.exec variations although I haven't written this myself so I don't know all the nitty gritty details. You may also need logic to make sure the parent process cleans itself up properly. I know there are projects out there including meteor.js and others that claim some form of "hot code loading" so there may be some prior art there you can study.

There isn't anything within the same process you can do, exiting it would return control back to the OS, which doesn't exactly do anything for you.

I would recommend trying nodemon instead. It watches files and restarts the server when it detects a change.