Start and keep running node.js instance

I'm trying to figure out how to keep a node.js instance running.

Right now I open up ssh and run "node server" and everything takes off and goes.  As soon as I close SSH obviously the server goes down.  I tried screen, but then my server unexpectedly quit last night, is there a better solution for starting it up and keeping it running? If crashes then restart it?
LVL 12
Nathan RileyFounderAsked:
Who is Participating?
 
BigRatCommented:
Try the "forever" package. There's a tutorial here http://www.slidequest.com/q/70ang
0
 
Jan SpringerCommented:
And, use forever in an init script.  If you have ubuntu, you can use upstart or systemctl if it's a later version.  With CentOS, you can easily create an init script.

This way, your job will start on boot, as well.
0
 
Nathan RileyFounderAuthor Commented:
I agree with this, worked for me.
0
 
Jan SpringerCommented:
The author was provided with the best solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.