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
8
votes
2 answers

How to configure pm2 with webpack for typescripts compile and reload?

Is there any boiler plate code to use pm2 with webpack watch option for ts files auto hot reload? pm2 start index.js is helpful to run directly, but how to add multiple tasks before doing it like watch files and auto reload using webpack and pm2…
Mithun Shreevatsa
  • 3,588
  • 9
  • 50
  • 95
8
votes
1 answer

How to make sticky session works with socket.io (w/ or w/o pm2)?

Although the socket.io document said 'sticky session' can make socket.io work with node cluster. I just can't make it work. I find pm2 had several issues opened against it, the closest solution I can find is this, "force to use websock option only",…
Qiulang
  • 10,295
  • 11
  • 80
  • 129
8
votes
2 answers

node app instance name when running via pm2 cluster

I have backend node app, that is run by pm2 in cluster mode. I'm running fixed 2 instances. Is there a way to identify instance name or number from within executed app? App name is "test", I would like to get from within the app "test 1" and "test…
pankleks
  • 693
  • 6
  • 14
8
votes
0 answers

pm2 running at 100% CPU - how to debug

Last couple of weeks, I am struggling with pm2 100% CPU usage which hangs my node server. I tried reading logs but I didn't find any issue there. My node version: 6.9.1 PM2 is : 2.4.4. OS: Ubuntu 14.04 On an average my cpu usage is : ~5 Manually I…
LookAtSrc
  • 153
  • 3
  • 8
8
votes
4 answers

Use pm2 with Django

I have just changed from Express with NodeJS to Django with Python. The only thing I miss about NodeJS was the wonderful process manager pm2. Can I use pm2 with Django?
ruttydm
  • 671
  • 2
  • 8
  • 15
8
votes
1 answer

PM2 - cannot start my node app using custom cwd in ecosystem.json

My node app is deployed in /opt/hello/current but when I start PM2 (pm2 startOrReload ecosystem.json --env production) with the following ecosystem.json , it doesn't seems to take in account the given parameters... "apps" : [ { "name":…
user762579
8
votes
3 answers

Edit existing PM2 process

I have an existing PM2 process that I would like to add the "--max-memory-restart" setting to. How can I do that? The process was created from the command line without a JSON file. If I were creating a new process I would just run: PM2 start…
Alex
  • 690
  • 1
  • 9
  • 29
8
votes
1 answer

pm2 difference between stop and delete app

In pm2 node app manager, what is the difference between stop and delete app. I know that delete app deletes the app, from the pm2:s control, but what does stop app do? They both will set node server to offline. My problem is that during deployment,…
Ville Miekk-oja
  • 18,749
  • 32
  • 70
  • 106
8
votes
4 answers

How can we configure master process when using PM2

I have an problem with PM2 in NodeJS. Without PM2, we always have some lines of code like below to configure master process if(cluster.isMaster){ //master process configuration } else { //worker process configuration } Exactly, I want to…
thelonglqd
  • 1,805
  • 16
  • 28
8
votes
2 answers

Pm2 process stops running

I have a node chat application that needs to keep running on my server (ubuntu with nginx). The problem is that the application stops after a few hours or days. When I check on the server I see that my pm2 list is empty. The code I use to start my…
Johan
  • 81
  • 1
  • 2
  • 5
8
votes
3 answers

Configuration parameters in pm2 to display colors in console

I use pm2 to keep my node.js app alive, I am starting my app with a configuration file that looks like this: { "name" : "myApp", "script" : "app.js", "log_date_format" : "YYYY-MM-DD HH:mm Z", "ignoreWatch" :…
Ced
  • 721
  • 1
  • 11
  • 21
8
votes
1 answer

Load balancing since Node v0.12.2 - cluster, pm2 or nginx

With Node v0.12.2, the cluster module supports Round-Robin (RR) load balancing, which ensures load is more evenly distributed than the previous OS-level load balancing. So now we are spoilt for choice: Use the cluster module Use pm2 which uses the…
dayuloli
  • 16,205
  • 16
  • 71
  • 126
8
votes
3 answers

NodeJS on multiple processors (PM2, Cluster, Recluster, Naught)

I am investigating options for running node in a multi-core environment. I'm trying to determine the best approach and so far I've seen these options Use built in cluster library to spin up works and respond to signals Use PM but, PM2 -i is listed…
Douglas Ferguson
  • 1,242
  • 2
  • 14
  • 25
8
votes
1 answer

node.js - PM2 log uncaught exceptions to third-party service (as Logentries)

I'm using pm2 (https://github.com/Unitech/pm2) in my node.js project. Also I'm sending logs of errors of the app in Logentries (https://logentries.com). I wonder is it possible to log uncaught exceptions from the app (when something fails badly and…
Kosmetika
  • 20,774
  • 37
  • 108
  • 172
8
votes
2 answers

How to use Grunt/Gulp with pm2?

pm2 is a great tool to manage node apps. How does it work with grunt/glup ? I didn't find any useful clues after Googling for 20 minutes.
wilbeibi
  • 3,403
  • 4
  • 25
  • 44