Questions tagged [pm2]

PM2 is a CLI process manager for Node.js applications with a built-in load balancer

pm2 is a process manager for Node apps with a built-in load-balancer.

pm2 is perfect when you need to spread your stateless NodeJS code across all CPUs available on a server, to keep all processes alive forever and to 0s reload them. pm2 reloads scripts when they crash, can manage multiple processes at once, and all without downtime.

It is an NPM CLI application that runs in io.js and node.js on Windows, Mac OSX, and Linux.

Main features

  • Builtin load-balancer (using the native cluster module)
  • Script daemonization
  • 0s downtime reload for Node
  • Startup scripts for Ubuntu and CentOS
  • Stop unstable process (avoid infinite loop)
  • Monitoring in console
  • HTTP API
  • Remote control and real time interface API

Questions can be tagged with "pm2" for problems with running applications using pm2.

For more information:

2258 questions
6
votes
4 answers

How to use PM2 Cluster with Socket IO?

I am developing an application that relies completely on Socket.io. As we all know NodeJS by default runs only on one core. Now I would like to scale it across multiple cores. I am finding it difficult to make socketio work with PM2 Cluster Mode.…
6
votes
3 answers

PM2 doesn't work on NodeJS (Heroku)

I'm using PM2 to let the NodeJS (Express) run continuously. On my local machine, the following works in my packages.json: "scripts": { "start": "pm2 start ./bin/www" } After that, I use 'npm start' to run my app. This all works fine. Now I want…
Soccerlife
  • 671
  • 3
  • 9
  • 20
6
votes
1 answer

Pm2 logs with huge size using pm2-logrotate

I'm having troubles with pm2. I'm using a module called pm2-logrotate but the logs have a huge gize like 1.7G and don't respect my configuration which is == pm2-logrotate == ┌────────────────┬───────────────┐ │ key │ value …
Cátia Matos
  • 820
  • 1
  • 8
  • 26
6
votes
1 answer

Prevent X-Forwarded-For spoofing using ELB and Node

I'm analyzing a stack of a public route that rests on an Elastic Load Balancer which opens a port exposed by PM2 that starts a node app using the koa module. At the moment, the IP is logged and that depends solely on the X-Forwarded-For header. If…
SomeGuyOnAComputer
  • 5,414
  • 6
  • 40
  • 72
6
votes
2 answers

Scaling websockets/ws with multiple server instances

I am using websockets/ws on single machine. Its working fine. I want to scale it horizontally on multi-core and on multiple instances. For mutli-core I tried with pm2 and it seems working great. First Q: Is this the best approach or suitable…
Gagan
  • 1,267
  • 3
  • 18
  • 28
6
votes
4 answers

Get Message Spawning PM2 daemon with pm2_home=/.pm2 always

On ec-2 instance whenever I execute pm2 I get the message... Spawning PM2 daemon with pm2_home=/.pm2 This occurs with pm2 info, pm2 list, pm2 -h etc. A bare pm2 will show help. I can get more response from sudo -i. It seems something is…
user3094755
  • 1,561
  • 16
  • 20
6
votes
1 answer

Using a batch file to start pm2 when windows starts?

I can't get pm2 to start my apps on Windows start. I'm running Windows Server 2012 R2 Standard and pm2 2.4.2. I have a pm2 process file in JSON format which I use to start all my apps. c:\pm2\process.json { "apps": [ { "name" :…
Stephen Last
  • 5,491
  • 9
  • 44
  • 85
6
votes
5 answers

No able to run pm2 on Windows server 2012

I installed pm2 on Windows server 2012 npm install pm2 -g I closed my PowerShell and opened it again. When I try to run pm2 it fails with this error > pm2 list pm2 : The term 'pm2' is not recognized as the name of a cmdlet, function, script file,…
zabumba
  • 12,172
  • 16
  • 72
  • 129
6
votes
3 answers

How to start the node.js application using pm2

I have installed pm2 module using the following command: npm install pm2@latest Then I tried to start my test application using pm2 as follows: $ pm2 start test.js It…
Prem
  • 5,685
  • 15
  • 52
  • 95
6
votes
5 answers

run node.js by pm2,but often restart:exited with code [0] via signal [SIGINT]

I am trying to run node.js on my system but running into this problem: 2016-06-01 20:46:28: App [app] with id [13] and pid [12633], exited with code [0] via signal [SIGINT] 2016-06-01 20:46:28: Starting execution sequence in -cluster mode- for app…
chelsh
  • 61
  • 1
  • 1
  • 2
6
votes
2 answers

Why are there multiple PM2 processes listed on my server?

I have a Node application running on a production server using PM2. When I ssh into the server and run htop I can see multiple PM2 God Daemon processes listed. I don't understand why there would be multiple processes since there's only one Sails app…
scottmcallister
  • 193
  • 3
  • 11
6
votes
2 answers

How do I configure pm2 to run hexo?

I've used pm2 in the past for my express apps. I really like it. How do I get it to run hexo. Hexo starts with hexo server rather than with a js entry point.
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
6
votes
1 answer

Pm2 cluster mode, The ideal number of workers?

I using PM2 to run my nodejs application. When starting it in cluster mode "pm2 start server -i 0": PM2 will automatically spawn as many workers as you have CPU cores. What is the ideal number of workers to run and why?
Jonatan Lundqvist Medén
  • 2,750
  • 1
  • 17
  • 15
6
votes
3 answers

PM2 cluster mode only starts one instance

I'm using PM2 for clustering. It worked just fine when using NodeJS 0.10.31 and PM2 0.12.14. I upgraded NodeJS to 0.12.4 and PM2 to 0.12.16 and now when launching the following command : pm2 start app.js -i 5 I get : [PM2] Spawning PM2…
Kwel
  • 97
  • 1
  • 7
6
votes
0 answers

How to include mongodb & redis on a startup script on ubuntu using PM2?

I run a node.js express app on an ubuntu digitalocean droplet. I'm using PM2 to start and monitor my app. I want to make sure - should the server needs to restart/crash, PM2 includes my Redis & Mongo services upon server restart as they are…
Ajar
  • 1,051
  • 3
  • 13
  • 29