使 nodejs 代码 在后端运行(forever)

情境

运行nodejs的程序,使用命令:node xxx.js,但是关掉终端,程序也关闭了,如何让node app的程序一直运行?

解决

1.安装forever

npm install -g forever

2.使用forever开启nodejs程序

forever start xxx.js

如果你需要用npm start来运行你的程序,则用命令
forever start -c “npm start” 路径

3.如果不需要一直运行nodejs程序

forever stop xxx.js

.

原文地址:https://www.cnblogs.com/crazycode2/p/11286309.html