簡體   English   中英

在開發服務器上使用永遠監控器運行NodeJS進程

[英]running a NodeJS process with forever-monitor on development server

我試圖使用永久監視器在服務器上連續運行我的expressJS應用程序。 我沒有收到任何錯誤,但是我的應用程序未按預期運行,在3次重啟后該過程退出了。 我可以在此處省略最大值還是連續運行該應用程序需要缺少什么?

信息:我正在將其部署到AWS Lightail服務器。

我實現的代碼來自永遠監控的git repo。

var forever = require('forever-monitor');

var child = new (forever.Monitor)('app.js', {
max: 3,
silent: true,
args: []
});

child.on('exit', function () {
console.log('program has exited after 3 restarts');
});

child.start();  

我必須同時安裝永久和永久監視依賴項才能使應用程序連續運行。 關閉CLI會話后,應用程序現在將按預期運行。

var forever = require('forever-monitor');

var child = new (forever.Monitor)('app.js', {
max:3,
silent: true,
sourceDir: '/app.js',
watch:true,
args: []
});

child.on('watch:restart', function(info) {
console.error('Restaring script because ' + info.file + ' changed');
});

child.on('restart', function() {
console.error('Forever restarting script for ' + child.times + ' time');
});

child.on('exit:code', function(code) {
console.error('Forever detected script exited with code ' + code);
});

child.start();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM