Loopback-next: Requesting guidelines for pm2 + nginx on linux

Created on 15 Oct 2018  路  7Comments  路  Source: strongloop/loopback-next

Description / Steps to reproduce / Feature proposal

I want to move from express to loopback 4, but there are some things that are kind of blocker for me. In all the examples I saw this far, there is no mention of how to run this on a simple linux server in production environment. All I want to do is run the APIs by pm2 and put this behind nginx. I just need to know if there are any gotchas or things to keep in mind while doing so. nginx configuration is pretty standard, but I am not sure how to run this app in production using pm2 with even default pm2 config. Any kind of documentation/bullet list would be great.

DevOps Docs help wanted

All 7 comments

Hi @vivekdwivedi, our focus is on running LB4 applications in the Cloud - see Deploying to IBM Cloud and the upcoming spike Deploy a basic LB4 application to IBM Cloud Kubernetes #1606.

Having said that, I am not aware of any issues preventing you from running LB4 applications with pm2. A LoopBack application is pretty much a standard Node.js server app which is started via node . and listens on the configured port for incoming HTTP requests.

A possibly missing piece is graceful shutdown to allow pm2 to restart workers with zero downtime, assuming this is something that pm2 supports (I am not familiar with pm2 features). I think such feature should be reasonably easy to implement, I can help you along the way if you decide to contribute it.

Hi @vivekdwivedi , loopback 4 is a Node JS application, so following their documentation to run it, bind it to multiple cpus, monitoring, deleting etc. works fine, with except of graceful shutdown as @bajtos is mentioning which we haven't tested yet.

The only problem I faced was running nginx in Centos 7, the configuration was like this but it wasn't reverse proxying properly, aside from that, we had pm2 running for 37 days without any problem. Is there any specific concern ?

 # let us configure The API end points
    location /bsiapi {
            proxy_pass http://localhost:8080;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
       }

screen shot 2018-10-15 at 08 03 54

I was able to run it on my local setup, but there was an error in aws. I just updated the cli and created a new app. This seems to be working. I will try the graceful shutdown scenarios and see if I can contribute later. Thanks for quick response.

I think it would be great if we could have a short page in our documentation explaining users that LB4 supports pm2 with no special configuration. Something similar to Deploying to IBM Cloud, but obviously much shorter :)

@vivekdwivedi @marioestradarosa what do you think? Would you be willing to contribute such guide?

sure @bajtos

Of course, I was waiting for GA release and life has been so simple after that. Would be happy to contribute in any possible way.

That's great @vivekdwivedi , you can contribute to the guide @bajtos is suggesting so the community can get the benefits of it. feel free to sign up the CLA and start contributing !!

Please sign CLA at https://cla.strongloop.com/agreements/strongloop/loopback-next

Was this page helpful?
0 / 5 - 0 ratings