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

react express pm2 deployment

Scenario I've made react app as well as a express server for API and both are separate. I've not included react folder in express app. I'm looking forward to deploy it using pre/post scripts using PM2 but I'm having hard time achieving exactly what…
Indrajeet Latthe
  • 374
  • 1
  • 8
  • 22
9
votes
3 answers

How to configure pm2 serve command to serve multi-page React app?

I created a ReactJS application using Create-React-App, and wanted to deploy it on a Linux server. I followed a tutorial that showed how to do so very simply by installing pm2 and serve, then after running the command: npm run build I ran the…
Karim Taha
  • 1,151
  • 3
  • 9
  • 14
9
votes
8 answers

Can't add new command when connection is in closed state

I am using the Amazon EC2 with Ubuntu. I am running the server using the PM2, as pm2 start bin/www --log-date-format "YYYY-MM-DD HH:mm" --watch It works fine but when I am trying to access API after 1 or 2 days. I will get the error: 0|www |…
Ankur_009
  • 3,823
  • 4
  • 31
  • 47
9
votes
3 answers

pm2, node, instances and ports

Sorry if this question is to 'newbie' but I can't see how to do it / how it works. 1/ I am creating an API using node.js, API serving some front apps 2/ To get it robust I use pm2 (great product), having nginx as proxy, fine 3/ But how could I…
Gregoire Mulliez
  • 1,132
  • 12
  • 20
9
votes
1 answer

Is there a way or a trigger to notify when there is an error and restart happened with PM2

I have an express application running and I am using PM2 to keep it alive and restart when there is any error in the system. PM2 logs the error and restarts which is perfectly fine. But I need to notify the user who submitted this with the error…
Bala Sivagnanam
  • 863
  • 1
  • 15
  • 30
9
votes
2 answers

How to see PM2 restart history (node-pm2)

Is it possible to see the restart log/history with PM2 app? I saw my nodeJS app restarted a few times but no clue when. I've checked pm2 documentation but no luck.
Thịnh Phạm
  • 2,528
  • 5
  • 26
  • 39
9
votes
2 answers

Can PM2 be used with compiled c programs

Is it possible to use pm2 with custom c programs? If so, how is this accomplished? Does it work well? Is you are already using pm2 for node.js apps would it make sense to use it for a c program as well?
Timothy Vann
  • 2,537
  • 2
  • 20
  • 23
9
votes
6 answers

How to remove pm2 from startup (on mac)

I experimenting with pm2, which is a process manager for node.js applications. I tried their pm2 startup utility which generates and installs a startup script for pm2 when the system restarts. I tried this on my mac, and it works flawlessly. The…
Shaunak
  • 17,377
  • 5
  • 53
  • 84
8
votes
3 answers

open api error: request should have required property '.headers' - docker

My nodejs app has an open-api.yaml file and express-openapi-validate validator. I'm doing a POST request which is working and the api validator doesn't return any errors: curl --request POST 'http://localhost:33004/my-app/settings' --data-raw…
m144
  • 305
  • 3
  • 13
8
votes
1 answer

How to find which error has caused pm2 to restart

I'm running a Node.js puppeteer script with pm2. It's important to keep this process stable. After 2 days of work I see 2 restarts in my pm2 stats. I want to find out what is causing the restarts. In my error logs I see 3 main errors: Error: Page…
hretic
  • 999
  • 9
  • 36
  • 78
8
votes
1 answer

docker-compose & pm2: container exiting immediately

I am a lowly frontend developer trying to improve by backend skills, and to that end I have written my API in nodejs and am using GitLab, AWS EC2, docker and pm2 to serve the backend. I am nearly there with a basic CI/CD setup in GitLab, but I have…
serlingpa
  • 12,024
  • 24
  • 80
  • 130
8
votes
1 answer

What's the best approach to keep node running in the background - nohup vs. forever vs. pm2?

I've read many posts that talk about keeping node running in the background using nohup, forever and pm2. But I'm still uncertain which is the optimal choice and would appreciate some guidance. Background - running a MEAN stack app on an Apache…
coder101
  • 383
  • 4
  • 21
8
votes
3 answers

Getting error when trying to launch node.js app with PM2 Cluster

in an Ubuntu Server, I am unable to run the node.js app in cluster mode using PM2. The command I use is : PM2 start server.js --name Server -i max When I list the PM2 processes, I can see the Server has Error status. I have tried looking into …
Benjamin
  • 3,499
  • 8
  • 44
  • 77
8
votes
2 answers

Export PM2 Cluster Stats to Prometheus

I am trying to add monitoring to a Node.js PM2 cluster where I am looking for aggregated stats in prometheus which I will then import in Grafana. I have been able to configure prom-client and get metrics for a single process to prometheus and…
Vignesh T.V.
  • 1,790
  • 3
  • 27
  • 48
8
votes
4 answers

Node.js getting SIGINT from pm2

I'm trying to use pm2 to run my node app as a service. Right now, starting and stopping the app works. However, I want to do a graceful shutdown. My app already listens for SIGINT, shutdowns the server and then exits the process. However, trying to…
Fede E.
  • 2,118
  • 4
  • 23
  • 39