且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更改文件后重新启动节点

更新时间:2023-01-26 15:28:51

永远模块的概念是多个node.js服务器,并且可以启动,重新启动,停止和列出当前正在运行的服务器.它还可以监视文件的更改并根据需要重新启动节点.

forever module has a concept of multiple node.js servers, and can start, restart, stop and list currently running servers. It can also watch for changing files and restart node as needed.

如果尚未安装,请安装:

Install it if you don't have it already:

npm install forever -g

安装后,调用forever命令:使用-w标志监视文件中的更改:

After installing it, call the forever command: use the -w flag to watch file for changes:

forever -w ./my-script.js

此外,您可以监视目录并忽略模式:

In addition, you can watch directory and ignore patterns:

forever --watch --watchDirectory ./path/to/dir --watchIgnore *.log ./start/file