Running Node Applications Continuously with Forever.js

code | 7-5-2013

When I first started writing Node applications, my main question was how I could keep the server running on a live server.

The answer I finally discovered was Forever. Forever is a CLI tool that keeps a node process running indefinitely. That means that you can ssh into the place where your code is hosted, start the server with Forever and then close your ssh connection and the server will still be running. It is a thing of beauty.

To install Forever, just run:

[sudo] npm install forever -g

Then you can start up the server as easily as:

forever start my-server-file.js

After that, you can just hit your site or application from whatever port the server file is starting it up at.

If you need to stop your all of your processes, run:

forever stopall

It's a thing of beauty!



About the Author

Tyson Cadenhead is a Senior JavaScript Developer at Aloompa. He lives in the greater Nashville area. His specialty is writing large, scalable JavaScript applications on the client and server side. His passions are for good design, usability, and clean, reusable code.

Tags: Node

Related Posts:

comments powered by Disqus

Don't Miss Anything!

Sign Up For My Email Newsletter

I Wrote a Book!

Popular Posts