Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elastic Beanstalk Node.Js needs PM2 or Forever

In my local node server , it fails on any uncaught exception and has to be manually restarted. So local was run using either forever or pm2. But my development server is AWS Elastic Beanstalk with Node.Js environment .Though it logs uncaught exceptions and throws it , it never terminates.Even if it terminates , it starts automatically. So is there a need for PM2 or Forever to keep node.js running for ever in AWS Elastic Beanstalk environment.

like image 303
Janier Avatar asked May 06 '17 19:05

Janier


People also ask

Does Elastic Beanstalk support node JS?

Elastic Beanstalk provides platforms for programming languages (Go, Java, Node. js, PHP, Python, Ruby), application servers (Tomcat, Passenger, Puma), and Docker containers.

How do you use the PM2 in Elastic Beanstalk?

Go to your application directory and use eb init to setup Beanstalk. We need to make sure Beanstalk will try to launch your application by using npm start . To do so, add a file called Procfile at the root of your source bundle to specify the command that starts your application.

Why we use PM2 in node JS?

PM2 is a production process manager for Node. js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.


1 Answers

My 2 cents:

There are many advantages for PM2 over EBS:

  1. with PM2 you can control and manage many applications (processes) with different platforms (JS, Ruby, ...). Where in EBS you can deploy only one application at a time to an EBS.

  2. PM2 gives you direct control over all running process, where you can reload/restart/stop one process and keep other intact.

EBS can fix only few problems for you, like restart on crash, or limit memory leaks. But PM2 gives you control over many other problems (graceful reload, 0 latency reload, ...) Now, I might be a little bit wrong about the full functionalities of EBS, and it might be providing more

like image 197
Ghassan Karwchan Avatar answered Nov 11 '22 06:11

Ghassan Karwchan