What is forever in nodejs?

落爺英雄遲暮 提交于 2019-12-05 04:09:35

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.

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.

Neeraj Soni

You can even use the nohup command it simply ignores the hang up signal.

node index.js && nohup -& (to run as a background process - no hiccup)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!