Node.js的重新启动对OpsWorks亚马逊每一分钟?亚马逊、重新启动、Node、js

2023-09-11 09:27:16 作者:少年与梦

我用OpsWorks在AWS上亚马逊。我订的Node.js应用程序就可以了,当我部署它的一切工作,因为它应该,但是我的主要脚本(server.js)正在重新启动完全的每一分钟。这是code是这样的:

I use OpsWorks on AWS amazon. I have set node.js app on it and when I deploy it everything works as it should, however my main script (server.js) is being restarted exactly every minute. This is what code looks like:

var database = require('./database');
var config = require('./config.json')['development'];

console.log('started');

process.on('uncaughtException', function(err) 
{        
    console.log(err);
});

foo();

function foo()
{   
    // some code
    setTimeout(foo, 2000);
}

为什么我会打印出开始每一分钟?

Why do I get printed out "started" every minute?

推荐答案

OpsWorks会检查你的应用程序中的每一分钟的健康并重新启动它的健康检查(HTTP GET)失败。重新启动它每分钟的事实表明,健康检查失败。请确保您的应用程序侦听端口80。

OpsWorks checks the health of your app every minute and restarts it the health check (HTTP GET) fails. The fact it is restarted every minute suggests that the health check is failing. Make sure your app listens to port 80.

应用程序必须侦听端口80(HTTP请求)或443(HTTPS请求)。

The application must listen on port 80 (for HTTP requests) or port 443 (for HTTPS requests).

如果你还有问题,请确保您的应用程序满足本文档中规定的条件:的部署的Node.js应用

if you still have issues, make sure your app meets the conditions laid out in this doc: Deploying Node.js Apps