我正在尝试使用永远保持我的nodejs脚本正常运行
根据 Forever 的主页,它说
[Long Running Process]
The forever process will continue to run outputting log messages to the console.
ex. forever -o out.log -e err.log my-script.js
[Daemon]
The forever process will run as a daemon which will make the target process start
in the background. This is extremely useful for remote starting simple node.js scripts
without using nohup. It is recommended to run start with -o -l, & -e.
ex. forever start -l forever.log -o out.log -e err.log my-daemon.js
forever stop my-daemon.js
但是我无法理解两者之间的区别。在什么条件下我应该使用长时间运行的进程而不是守护进程?
答案1
区别在于will continue to run outputting log messages to the console
部分。守护进程是一个长时间运行的进程,没有任何对最初启动它的控制台的引用。
删除引用需要几个额外的步骤(关闭原始输入和输出文件描述符),称为“分离”。