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

Merging/namespacing PM2 apps

There is PM2 configuration, /home/foo/someconfig.json { "apps": [ { "name": "foo-main", "script": "./index.js", }, { "name": "foo-bar", "script": "./bar.js" }, …
Estus Flask
  • 206,104
  • 70
  • 425
  • 565
12
votes
3 answers

Node JS pm2 maximum memory limit

I'm using pm2 and node js. What I want to do is set a maximum memory limit for an application. My dev server's limit is 500mb split between two applications. Ideally I would like to limit it to 200mb. I need this limit to be a hard limit for the…
N8ALL3N
  • 375
  • 1
  • 2
  • 14
12
votes
2 answers

How do you use pm2 startup with a non-root user?

According to the documentation here: http://pm2.keymetrics.io/docs/usage/startup/#startup-systems-support You can use the command pm2 startup ubuntu -u nodeapps to resurrect all saved pm2 jobs on server startup. I ran this command as the nodeapps…
Zach Smith
  • 8,458
  • 13
  • 59
  • 133
12
votes
2 answers

Error: Cannot find module '/Users/wyb/.nvm/versions/io.js/v3.0.0/lib/node_modules/pm2/lib/ProcessContainerFork.js'

After removing the older version of nvm, i installed the latest version of node by using homebrew. However, i got some problem starting my project using pm2: pm2-dev server.js It loaded the path including nvm. Here is the log: Error: Cannot find…
wyb
  • 123
  • 1
  • 4
12
votes
2 answers

How to get logging working with pm2 and Heroku

Is there a way to tell pm2 to leave stderr and stdout alone (as opposed to writing to files)? I'm using pm2 on Heroku using this gist as my model. Everything seems to work perfectly except that I've lost any ability to log from within my app. They…
uooq
  • 911
  • 8
  • 12
12
votes
1 answer

pm2 start app.js is exiting after 15 restarts

npm start will start my app just fine but when I do: pm2 start app.js I get: [PM2] Spawning PM2 daemon [PM2] PM2 Successfully daemonized [PM2] Process app.js…
cakes88
  • 1,857
  • 5
  • 24
  • 33
12
votes
3 answers

Using PM2, how can I deploy my node.js app to multiple environments and ports on the same server?

I have an ecosystem.json file for my node app that I deploy using PM2. I've tried configuring it a bunch of different ways, but have not had luck accomplishing my goal which is to: be able to deploy to either production or staging environment…
k00k
  • 17,314
  • 13
  • 59
  • 86
12
votes
4 answers

PM2 change cluster processes size at runtime

does anyone know if it is possible to change in NodeJS PM2 the number of cluster processes for an application at runtime? regards Philipp
Philipp
  • 177
  • 1
  • 1
  • 10
11
votes
3 answers

Is there a way to only show log based on a keyword in pm2?

How do I use pm2 to log only based off a keyword? This is how pm2 is being called currently: package.json file "services": "pm2 start pm2.config.js --no-daemon",
Rod
  • 14,529
  • 31
  • 118
  • 230
11
votes
3 answers

How to only restart node process with PM2 if exit code != 0

I'm using pm2 to manage a node process. Currently, pm2 restarts the node process even if it finishes cleanly (with exit code 0). I don't want that to happen. Instead I only want PM2 to restart the app when the node process exits with a code != 0.…
Geert-Jan
  • 18,623
  • 16
  • 75
  • 137
11
votes
2 answers

How to hide node cmd windows created by "pm2 start"

One cmd window per node process, I don't know what these windows for. Can I hide them?
Doctor.Who.
  • 607
  • 1
  • 7
  • 15
11
votes
1 answer

Disable pm2 log creation in node js

I am using aws ubuntu instance for my application and using node js to sync data from third party apis. I have 6 node js scripts that calls every minute to sync data by making http request for many users. For process management I am using PM2 module…
Ankit Badiya
  • 451
  • 1
  • 4
  • 17
11
votes
1 answer

Should PM2 God Daemon always be running?

I use pm2 to deal with node projects. Even when all projects are stopped via pm2, I see that pm2 God Daemon is always running and consuming about ~27M Ram. Here how it looks on ps aux: nodeuser 2577 ? Ssl 18:02 0:01 PM2 v0.15.10: God…
fcukinyahoo
  • 313
  • 1
  • 5
  • 16
11
votes
5 answers

Proper way to update PM2 after updating Node.js

After updating Node.js from v10.16 to v10.32, PM2 was not detected, however it was running fine when checked with ps aux. Even upon system reboot PM2 functioned correctly even though manual PM2 commands resulted in following type of error. pm2…
Nels
  • 113
  • 1
  • 1
  • 6
10
votes
2 answers

Node.js Debugger ends as soon as it is attached

I'm currently using WebStorm as IDE and my project uses pm2 as process manager. The structure of my ecosystem is the following: module.exports = { name: 'myProject', cwd: __dirname, script: 'npm', args: 'run start:debug', }; which…