Reputation: 1343
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?
Upvotes: 1
Views: 6947
Reputation: 291
i know this is old; but, my CentOS will not "sudo yum install forever" - gives error: "No package forever available". so i tried
"sudo -u [appuser] nohup node [path_to_your_app] > [path_to_log_file] 2>&1 &", where;
[appuser] = admin
[path_to_your_app] = server.js
[path_to_log_file] = log.txt.
still, in 5 min the sever timed out due to "broken pipe" and web page running via node server, stopped.
Upvotes: 0
Reputation: 26199
You need to daemonize your application. There are many different ways to do it.
You can start your application with nohup util:
sudo -u [appuser] nohup node [path_to_your_app] > [path_to_log_file] 2>&1 &
Upvotes: 4