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
13
votes
5 answers

PM2 keeps getting killed every 90 seconds on centos 8

I just installed CentOS 8 and added nodejs (tried v12 & v14) And then I installed pm2 using npm install pm2@latest (so at the time of posting it uses v4.4.0). I did try an older version (v3.5.0), but it does the exact same thing. and after pm2 got…
Alex Laz
  • 339
  • 2
  • 6
13
votes
2 answers

pm2 not working with experimental-modules flag

I am using ES6 modules by adding the --experimental-modules arguments to Node. Running node --experimental-modules app.mjs works perfectly fine. However, when I run the same command with pm2 I get the following error: Error [ERR_REQUIRE_ESM]: Must…
user2600769
  • 155
  • 2
  • 8
13
votes
7 answers

How to run nuxt under pm2?

I have 2 nuxt projects that need to be run on the server. Whenever I run the app locally it seems to be working with:npm run dev, but on the server this needs to be ran under a subprocess, so I use pm2 for that. But whenever I start running the same…
Edito
  • 3,030
  • 13
  • 35
  • 67
13
votes
2 answers

Using pm2 to do yarn start gives error while npm start works fine

I have a NodeJs microservice. Doing yarn start normally works perfectly fine. When I try to use pm2 to start this as a background service, facing the below issue: /Users/sairamk/.pm2/logs/api-error-21.log last 15 lines: 21|api |…
Sairam Krish
  • 10,158
  • 3
  • 55
  • 67
13
votes
5 answers

What exact command is to install pm2 on offline RHEL

First of all it's not a duplicate question of below:- How to install npm -g on offline server https://stackoverflow.com/questions/40976100/how-to-installl-pm2-on-offline-server I install npmbox (https://github.com/arei/npmbox) on my offline REHL…
Jitendra Pancholi
  • 7,897
  • 12
  • 51
  • 84
13
votes
7 answers

How Can I run PM2 with Angular-Cli? - Angular2

How can I run: ng serve --prod with pm2? ng serve from angular-cli, Angular2. I'm running on DigitalOcean. I have tried to test with http-server -p 4200 -d false in the dist/ folder after ng build --prod When I request from the domain…
Vicheanak
  • 6,444
  • 17
  • 64
  • 98
13
votes
5 answers

Disable restarting in PM2

I need to stop my nodejs app for some conditions.So I have used process.exit() method. I am running my app with PM2. But PM2 is restarting the app whenever it was stopped. So is there any possibility to disable restarting in PM2.
kamesh
  • 391
  • 2
  • 3
  • 11
13
votes
1 answer

Make PM2 run job only once every 10 minutes

I have the following .json configuration for a job that I need to run once every 10 minutes and then do nothing for the remaining time... "name" : "test.10minjob", "cron_restart": "*/10 * * * *", "autorestart" : false, "exec_mode" :…
AyKarsi
  • 9,435
  • 10
  • 54
  • 92
13
votes
4 answers

How to watch and reload an ExpressJS app with pm2

I'm developing an ExpressJS app. I use pm2 to load it: myapp$ pm2 start bin/www This works fine, except that adding the --watch flag doesn't seem to work; every time I change the JS source I need to explicitly restart it for my changes to take…
John J. Camilleri
  • 4,171
  • 5
  • 31
  • 41
13
votes
1 answer

SlimerJS extensions.getAddons.cache.enabled

I'm having an issue running SlimerJS through CasperJS, I get the next message "1414441945905 addons.repository WARN cacheEnabled: Couldn't get pref: extensions.getAddons.cache.enabled". I have a nodejs scraper running with CasperJS and Slimer…
XcKoN
  • 131
  • 4
12
votes
7 answers

pm2 Unexpected token import

I have a webserver that works when I use node or nodemon (e.g. "nodemon index.js"). However, when I try to use pm2 ("pm2 start index.js"), I get "SyntaxError: Unexpected token import". The full error log is below. What am I doing wrong…
Jeff
  • 127
  • 1
  • 1
  • 5
12
votes
2 answers

"systemctl start pm2-user-name" gives ERROR

I’m setting up a new server and trying now to get pm2 installed and working following this instructions https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-18-04 When trying sudo systemctl…
12
votes
1 answer

PM2 using wrong node.js version

I had node version v6.11.1 installed but it was giving error in some package, so i installed v10.15.3 with nvm and set it as default. #If I run my app directly using node, it uses correct node version v10.15.3 and works node server.js #If I run…
Andro
  • 381
  • 1
  • 4
  • 9
12
votes
5 answers

how to run "npm start" by PM2?

I have seen many questions here but that was not working for me. That why asking this question? I am using DigitalOcean Ubuntu 16.04 server. I have a node project run by "npm start". Script is: "scripts": { "start": "node…
user10311791
12
votes
5 answers

Is there a way to restart pm2 process using cron but only if it's not already running?

I want to restart my Node.Js app using PM2 through pm2 restart app.js using crontab but ONLY if the app is not already running (e.g. if my server crashed and restarted and pm2 didn't restart). the command above restarts it anyway even if it's…
Aerodynamika
  • 7,883
  • 16
  • 78
  • 137