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.
-
1Nodejs process is fully managed by Elastic beanstalk but you can customize your instances using `.ebextensions/web.config` file [Advanced Environment Customization](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html) – Ezzat May 06 '17 at 22:11
-
does Elastic beanstalk keep nodejs forever? How is the restart happening? – Janier May 07 '17 at 00:16
-
1@Janier 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. – Capaj May 02 '19 at 08:46
2 Answers
My 2 cents:
There are many advantages for PM2 over EBS:
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.
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

- 3,355
- 7
- 37
- 65
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!

- 5,781
- 5
- 40
- 47
-
3My 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.. – Janier May 17 '17 at 22:28