Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to restart node application automatically on aws elastic-beanstalk

Tags:

I have googled this question for a while but can't find the answer. My question is while deploying the nodejs application on aws elastic-beanstalk servers, I want the nodejs application would be restart automatically if the application crash.

Actually there're few nodejs package already support this by command line, such as forever, but there's no easy way from console management or awscli to install this package and execute it to achieve restart automatically.

I am wondering how do you resolve the restart issue on aws eb?

like image 530
HolaMan Avatar asked Nov 07 '13 12:11

HolaMan


People also ask

What are the three main services that Elastic Beanstalk uses to launch your application?

You simply use the AWS Management Console, a Git repository, or an integrated development environment (IDE) such as Eclipse or Visual Studio to upload your application, and Elastic Beanstalk automatically handles the deployment details of capacity provisioning, load balancing, auto-scaling, and application health ...

How do I reset my Elastic Beanstalk?

You can go to EC2 -> Auto Scaling Groups . Then change the Health Check Type of the load balancer from EC2 to ELB . By doing this, your instances of the Elastic Beanstalk will be terminated once they are not responding. A new instance will be created to replace the terminated instance.


1 Answers

I've confirmed (as of Mar 11, 2015) that EB does indeed restart node for you.

To confirm, I added a hidden query param to my app:

if (req.query.testcrash == 'true') {     setTimeout(function(){         undefined.crashMe();     }, 100); } 

Then verified in the log that the exception happened, and that my app was restarted.

For reference:

  • My EB/EC2 config is "64bit Amazon Linux 2014.09 v1.0.9 running Node.js"
  • Using nginx and node 0.10.31
like image 52
ryanman Avatar answered Sep 20 '22 14:09

ryanman