Node.js how to keep it running on CentOS?

Recently I have setup Node, Express and Jade on a CentOS 6.5 box with no other web servers or anything. I have the site working but in order to keep it up and running I have to leave a putty window open with the server running. So far no issue but if I lose power or internet my SSH connection is lost and the site goes down. Is there a way to keep my app.js running regardless of my SSH state?

You need to daemonize your application. There are many different ways to do it.

  1. You can use daemon module for node.js.
  2. You can start your application inside of 'screen'.
  3. You can start your application with nohup util:

    sudo -u [appuser] nohup node [path_to_your_app] > [path_to_log_file] 2>&1 &