How to Work Forever on Node.js with AWS Elastic Beanstalk

I tried to install forever in the package and in the start command in Elastic Beanstalk, I used the command ./ node_modules / forever / bin / forever start app.js. But it does not seem to start forever, like the behavior, and the workflow can still die.

Does anyone run forever with an elastic beanstalk? Need some advice. Thank.

+4
source share
1 answer

It was difficult, but here is how I did it. Not sure if this is the best practice or not.

index.js, server.js, Elastic Beanstalk. server.js forever-monitor

/*
 * Start server in production
 */

if(process.env.NODE_ENV == 'production') {

    var child = new (forever.Monitor)('index.js', {
        silent: false,
        args: []
    });

    child.start();

}
+4

All Articles