Run node.js application permanently after exiting terminal

Have you ever came across the problem that you launch your app from putty on an address you can get it

but when you close the putty you cannot reach it?. Let's see what happens when you close putty. You

have started an SSH Linux process when you log into remote host on putty when you close putty you are

exiting the SSH session and its active child processes. Closing the putty can kill the server because the

process is running in the foreground. Run the process in the background by appending & to the

command.

node /srv/www/MyUserAccount/server/server.js &

The node server may still die when you exit putty this is because even though the node process is

running in the background the stderr and stdout still points at the terminal. If the node writes to

console.log or console.error it will point at terminal and receives a broken pipe error. Piping the output of

your process can avoid this.

node /srv/www/MyUserAccount/server/server.js > stdout.txt 2> stderr.txt &