Search code examples
node.jsamazon-web-servicesamazon-elastic-beanstalk

how to restart node application automatically on aws elastic-beanstalk


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?


Solution

  • 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