how to restart node application automatically on aws elastic-beanstalk
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') {
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