Elastic Beanstalk Node.Js needs PM2 or Forever
Asked Answered
L

2

10

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.

Lipp answered 6/5, 2017 at 19:21 Comment(3)
Nodejs process is fully managed by Elastic beanstalk but you can customize your instances using .ebextensions/web.config file Advanced Environment CustomizationMiracidium
does Elastic beanstalk keep nodejs forever? How is the restart happening?Lipp
@Lipp in my experience it does. When the process ends it will just start it again immediately. This leads to situations where if you have an error on startup it will eat up the instance CPU credits like crazy because it just restarts the node.js app in a loop. Also you should have a /health route and EB replaces/restarts your instance when it detects that the health is failing. This takes care of situations when you crash/freeze your whole OS on the instance, for example when you run out of system memory.Sycamore
S
3

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

Softboiled answered 4/12, 2017 at 18:42 Comment(0)
T
1

Here is a tutorial on how to use PM2 in EBS:

http://pm2.keymetrics.io/docs/tutorials/use-pm2-with-aws-elastic-beanstalk/

Hope it helps!

Tumer answered 17/5, 2017 at 13:9 Comment(1)
My question is it necessary to use PM2 in EB since when ever my application fails on uncaught exception , it gets brought up automatically by elasticbeanstalk..Lipp

© 2022 - 2024 — McMap. All rights reserved.