[英]Node.js and Forever / Forever-Montior
I am currently using forever-monitor to spawn a basic HTTP Node Server, although when I execute the JavaScript that executes the forever-monitor scripts, it isn't sent to the background, when I exit the TTY session, the HTTP server stops. 我当前使用的是永久监视程序,以生成基本的HTTP节点服务器,尽管当我执行执行永久监视脚本的JavaScript时,它不会发送到后台,当我退出TTY会话时,HTTP服务器会停止。
The code I am using to spawn the server follows. 我用来生成服务器的代码如下。
The question I am asking really is, should I be using Forevers CLI to spawn the script that spawns subsequent servers programatically? 我真正要问的问题是,是否应该使用Forevers CLI生成以编程方式生成后续服务器的脚本?
var forever = require('forever-monitor');
var child = new (forever.Monitor)('streams.js', {
max: 3,
silent: true,
options: []
});
child.on('exit', function () {
console.log('streams.js has exited after 3 restarts');
});
child.start();
You can either start that script with forever by running 您可以通过运行永久地启动该脚本
forever start [your-script.js]
or if you don't want to install Forever's CLI you can just run 或者如果您不想安装Forever的CLI,则可以运行
nohup node [your-script.js] > nohup.log &
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.