skip to Main Content

I’m trying to run an old Node.js project in AWS Elastic Beanstalk. It sometimes crashes and the environment health goes to "Degraded," but instead of restarting the container, EB just leaves it hanging.

Looking at the logs, it appears that the container exits due to some socket.io error.

This question has been asked before, but this answer, this answer, and this reddit comment all suggest configuring a load balancer. However, I have a single-instance application and I have no load balancer at all.

Is it possible to have EB restart single-instance applications automatically?

2

Answers


  1. A ELB (Load Balancer) can be used even with only one instance and might things easier if you want to scale-out in the future or consider other deployment strategies. So there is no technical harm in using one (except that it cost more, but that’s financially).

    Login or Signup to reply.
  2. Instead of restarting the entire EB Application it’s better to Dockerize the app, and restart the Docker itself when it failed.

    1. Set the Restart policy in the Dockerfile as following
        CMD ["apache2ctl", "-D", "FOREGROUND", "--restart=on-failure"]
    
    1. Dockerrun.aws.json file and deploy the code using EB CLI
        {
          "AWSEBDockerrunVersion": "1",
          "Image": {
            "Name": "<your-image-name>"
          },
          "Ports": [
            {
              "ContainerPort": "80"
            }
          ],
          "RestartPolicy": {
            "Name": "on-failure",
            "MaximumRetryCount": 5
          }
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search