I tried to install forever in the package and in the start up command in Elastic Beanstalk, used the command "./node_modules/forever/bin/forever start app.js. But it seems it doesn't start the forever like the behaviour intended and the worker thread can still die.
Anyone runs forever with elastic beanstalk? Need some advice. Thanks.
This was tricky, but here's how I did it. Unsure of if this is best practice or not.
I moved my main application to index.js and I made a server.js file that would be automatically executed by Elastic Beanstalk. In my server.js file, I did this, after installing forever-monitor
/*
* Start server in production
*/
if(process.env.NODE_ENV == 'production') {
var child = new (forever.Monitor)('index.js', {
silent: false,
args: []
});
child.start();
}