AWS EBS 节点应用程序无法自动重新启动。

huangapple go评论66阅读模式
英文:

AWS EBS Node app failing to restart automatically

问题

我们在AWS Elastic Beanstalk(EBS)上部署了一个Node应用程序,但当应用程序崩溃时,它不会自动重新启动。

我们使用nodemon命令来运行应用程序。以下是package.json中的命令:

"scripts": {
    "start": "nodemon --expose-gc --max-old-space-size=4096 --exec babel-node app.js"
}

我们还有一个Procfile,其中包含以下内容:

web: npm start

应用程序崩溃后,我们可以在eb-engine.log中看到以下内容:

web: #033[31m[nodemon] app crashed - waiting for file changes before starting..

但应用程序没有重新启动。我们尝试过使用pm2和forever替代nodemon,但没有帮助。

请告诉我们我们漏掉了什么。我找不到关于这个主题的适当文档。

提前感谢。

英文:

We have a node application deployed in AWS Elastic Beanstalk (EBS) and when app crashes it is not getting restarted automatically.
We are using nodemon command to run the app. Below is the command in package.json

 "scripts": {
     "start": "nodemon --expose-gc --max-old-space-size=4096 --exec babel-node app.js"
  }

We also have a Procfile which have below content

web: npm start

After app crashes we can see below in eb-engine.log

web: #033[31m[nodemon] app crashed - waiting for file changes before starting..

But app is not restarting. We tried pm2 and forever instead of nodemon but didn't help.

Let me know what we are missing. I couldn't find proper documentation around this topic.

Thanks in advance.

答案1

得分: 1

Elastic Beanstalk支持自动扩展,因此您无需使用nodemon或pm2,只需将应用程序启动为Node应用程序:node app.js

现在,如果您希望自动扩展替换应用程序停止响应的实例,您可以使用配置文件来配置自动扩展组以使用Elastic Load Balancing健康检查:

示例 .ebextensions/autoscaling.config

Resources:
  AWSEBAutoScalingGroup:
    Type: "AWS::AutoScaling::AutoScalingGroup"
    Properties:
      HealthCheckType: ELB
      HealthCheckGracePeriod: 300
英文:

Elastic Beanstalk supports Auto Scaling so you don't need to use nodemon or pm2, but simply start you app as a node application: node app.js.

Now if you want Auto Scaling to replace instances whose application has stopped responding, you can use a configuration file to configure the Auto Scaling group to use Elastic Load Balancing health checks:

Example .ebextensions/autoscaling.config

Resources:
  AWSEBAutoScalingGroup:
    Type: "AWS::AutoScaling::AutoScalingGroup"
    Properties:
      HealthCheckType: ELB
      HealthCheckGracePeriod: 300

huangapple
  • 本文由 发表于 2023年7月3日 14:43:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76602394.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定