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?

AWS cli elasticbeanstalk

How does one create an rds db along with the aws cli for elastic beanstalk? aws elasticbeanstalk create-environment I was able to make the command create a new elastic beanstalk environment but it di

how to make Android Application restart automatically on phone restart

how to make Android Application restart automatically on phone restart. i made an app for android and now i want that it will restart automatically when phone is restarted ,can anyone please help me o

How does ElasticBeanStalk deploy your application version to instances?

I am currently using AWS ElasticBeanStalk and I was curious as to how (as in internally) it knows that when you fire up an instance (or it automatically does with scaling), to unpack the zip I uploade

How to automatically install an SSL cert on an AWS ElasticBeanstalk running on Windows & .NET?

Is there a way to automatically deploy a .NET/Windows based Amazon Elastic Beanstalk instance with an SSL cert? I already have the DNS for the domain in the SSL cert setup to point to the Beanstalk in

Automatically restart node server [closed]

How can I automatically restart my node js server every 4 hours automatically. There is a bug that only shows up after 4 hours and I want to be able to run it through the night. I’m already using fore

AWS Elasticbeanstalk deployment error

We are seeing the following errors being thrown while deploying a new application version on to our elasticbeanstalk environment(Tomcat 7 , Java 6). The eb-version-deployment.log on a running backend

ALLOW_ENCODED_SLASH on AWS Elasticbeanstalk

How should I configure my ElasticBeanstalk on AWS to allow encoded slashes in URLs ? (Using -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true) I’ve created a directory called .ebextension

Amazon AWS ElasticBeanstalk custom AMI

I am trying to use a custom AMI in AWS Beanstalk. I manually launched a default Amazon ElasticBeanstalk image in EC2 (ElasticBeanstalk-Tomcat7-32bit-20110913-1132 (ami-278e4c4e)) and created my custom

Can I deploy automatically to AWS ElasticBeanstalk? SSH or so?

I have a simple PHP application, which doesn’t use any database, or anything else. I have a script, which asks me for version name and than creates ZIP with the site and upload via the web interface.

Using AWS elasticbeanstalk, when I do ‘git aws.push’ where in the filesystem is the application pushed?

Using AWS Elasticbeanstalk, I push my code using ‘git aws.push’. When I then log into the linux box with ssh, where can I expect to find my project folder?


Yes, better option to use Supervisor, however in order to have ability to restart app server with help of aws console or beanstalk cli tools you need to put own handler to Elastic beanstalk hooks in the directory: /opt/elasticbeanstalk/hooks/restartappserver/enact Hook is shell, python or ruby script that placed in mentioned directory. Put logic of the supervisord restart here and you will be able to restart it with help of management console, aws cli tools (, elastic beanstalk api: (

How to add hook, install supervisiord etc you can read here:

Add forever to your package.json so it gets installed automatically. Then in EB console, under configuration, custom node command:

node_modules/.bin/forever app.js

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') {
    }, 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

If you want to restart the server from cron then you could use these commands.

aws elasticbeanstalk restart-app-server --environment-name my-env