Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is forever in nodejs?

Tags:

I am having hard time understanding what is forever in nodejs.

Can someone explain what is forever in simplest way that i can understand and what is the purpose of it

like image 734
Agent69 Avatar asked Oct 05 '15 07:10

Agent69


2 Answers

forever is a node.js package that is used to keep the server alive even when the server crash/stops. When the node server is stopped because of some error, exception, etc. forever automatically restarts it

From the npmjs https://www.npmjs.com/package/forever

A simple CLI tool for ensuring that a given node script runs continuously (i.e. forever)

Forever can be used as

forever start app.js 

It provides many useful functions which you can see in the link above.

Directly quoting from http://blog.nodejitsu.com/keep-a-nodejs-server-up-with-forever/

The purpose of Forever is to keep a child process (such as your node.js web server) running continuously and automatically restart it when it exits unexpectedly.

like image 104
Tushar Avatar answered Oct 15 '22 20:10

Tushar


Forever basically allows you to run your nodejs application as a process.

Without forever you might type npm start or node index.js to start your application and it will run in your terminal session.

With forever, you can start it off and still have access to your terminal session/close it.

like image 25
Matt The Ninja Avatar answered Oct 15 '22 19:10

Matt The Ninja