简体   繁体   English

Node.js在OpsWorks亚马逊上每分钟重启一次?

[英]Node.js restarting every minute on OpsWorks amazon?

I use OpsWorks on AWS amazon. 我在AWS亚马逊上使用OpsWorks。 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. 我已经在其上设置了node.js应用程序,当我部署它时,一切正常,但我的主脚本(server.js)正在每分钟重新启动。 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 checks the health of your app every minute and restarts it the health check (HTTP GET) fails. OpsWorks每分钟检查一次应用程序的运行状况,然后重新启动运行状况检查(HTTP GET)失败。 The fact it is restarted every minute suggests that the health check is failing. 它每分钟重新启动的事实表明健康检查失败。 Make sure your app listens to port 80. 确保您的应用监听端口80。

The application must listen on port 80 (for HTTP requests) or port 443 (for HTTPS requests). 应用程序必须侦听端口80(对​​于HTTP请求)或端口443(对于HTTPS请求)。

if you still have issues, make sure your app meets the conditions laid out in this doc: Deploying Node.js Apps 如果您仍有问题,请确保您的应用符合本文档中规定的条件: 部署Node.js应用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM