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
21
votes
4 answers

Running NodeJs http-server forever with PM2

My question is about running HTTP-server in combination with PM2. The problem I face is that: HTTP-server requires as input a folder which is the root of the website and a port number to run the website on. PM2 doesn't recognize the HTTP-server…
Guy Hagemans
  • 496
  • 1
  • 4
  • 15
20
votes
6 answers

Can I use pm2 to keep a Next.js app running

I have an AWS EC2 that is just for keeping my Next.js client side running (there is no backend for it right now). Currently if I go into the terminal and enter npm run develop, the site runs perfectly. However, I want this process to always be…
optionalfigure
  • 269
  • 1
  • 2
  • 9
20
votes
3 answers

Run Typescript application with PM2

I have an application written in Typescript that runs with PM2. Currently I compile to JavaScript, then use PM2 to start the app. My ecosystem.config.js file looks like this: module.exports = { apps: [ { name: 'My Application', …
CaribouCode
  • 13,998
  • 28
  • 102
  • 174
20
votes
2 answers

What are active handles in Node.js

I see that my applications active handle count keeps on increasing. What exactly is the number of active handles ? Is this something i have to take care of preventing the app from crashing?
Balanarayanan
  • 481
  • 1
  • 5
  • 11
20
votes
5 answers

PM2 (Node.js) not listening on specified port

I am trying to get a Node/Express application up and running on PM2. I can start the application fine with this command: npm start This starts the app fine on port 3000. If I try to start the application with pm2 start app.js I get the following…
JamesE
  • 3,833
  • 9
  • 44
  • 82
19
votes
4 answers

Why is PM2 not launching my Node process?

Previously I have had success implementing PM2, but not currently. My node app does run just fine if I start it manually, but nothing I do gets it to run via PM2, even though PM2 appears to be starting it up. Here's what I mean: If I run pm2…
208_man
  • 1,440
  • 3
  • 28
  • 59
19
votes
1 answer

pm2 --max-restarts limit not working and continuous restarting crash host system

I tried pm2 to restrict restart limit with --max-restarts but it's not working and also tired min_uptime sudo pm2 start server.js --max-restarts=5 And I also tried with yml file apps: - name: node-mt script: server-socket.js watch: true …
Adiii
  • 54,482
  • 7
  • 145
  • 148
19
votes
3 answers

Reload PM2 configuration file

I have problems with reloading PM2 configuration file after editing it: { "apps": [ ... { "name": "foo", "script": "foo/index.js", "cwd": "foo", "watch": false } ] } I…
Estus Flask
  • 206,104
  • 70
  • 425
  • 565
19
votes
8 answers

How can I check if my pm2 app NODE_ENV is getting set?

So I just deployed a site with node and pm2 for the first time and I'm going back and doing some optimization and reading best practices, etc. I read that you can get a lot of benefit by setting NODE_ENV=production. I found this in the pm2…
Kenmore
  • 1,525
  • 3
  • 16
  • 39
19
votes
7 answers

Node.js pm2 keeps restarting almost every second

I have deployed an express.js app on a Azure server. I use pm2 for process management. The issue is pm2 keeps restarting almost every seconds. staging@Server:/srv/apps/myapp/current$ pm2…
Sebin
  • 1,044
  • 1
  • 8
  • 21
19
votes
2 answers

How to Run Sails in production with pm2 (sails lift --prod) with pm2

How to lift sails in production with pm2 ?? I mean what is the the command of pm2 to get similar action like below command. sails lift --prod like we can run sails lift as pm2 start app.js In pm2 we can specify command line arguments after -- I…
Satyam Koyani
  • 4,236
  • 2
  • 22
  • 48
19
votes
3 answers

How to reset the id of pm2?

I using pm2. After I started my app several times, the id increased. I deleted all in pm2, and started again, but the id didn't count from 0 any more. How can I reset it?
Yao Zhao
  • 4,373
  • 4
  • 22
  • 30
18
votes
1 answer

PM2 - CPU 100% usage

I have an express server running with pm2(v2.4.2) and node(v7.7.4). Here is the pm2 list screenshot: Here is htop screenshot: As you can see, the CPU usage is 100%. And the running PIDs are not match with pm2 list. My server would get no response…
Hom
  • 421
  • 1
  • 4
  • 7
18
votes
5 answers

permission denied, mkdir in container on openshift

I have a container with nodejs and pm2 as start command and on OpenShift i get this error on startup: Error: EACCES: permission denied, mkdir '/.pm2' I tried same image on a Marathon hoster and it worked fine. Do i need to change something with…
ivoba
  • 5,780
  • 5
  • 48
  • 55
18
votes
3 answers

How do I limit the number of auto-restarts on pm2?

I have a node server running on pm2 which depends on some external services. When those servers go down I pm2 starts restarting my app, but this will keep going until it clogs up my cpu and ram on the server, restarting as much as 50 times a…