w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to run forever on Node.js with AWS Elastic Beanstalk

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();

}




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.