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
0
votes
1 answer

how to host multiple node application on multiple ports - port hardcoded in package.json

I have a node application runs a node JS server on port 1407 (hardcoded in server.js - using express) and also runs two react applications on port 3000 and port 3001. I am using concurrently to be able to run multiple npm commands from one npm…
lky
  • 1,081
  • 3
  • 15
  • 31
0
votes
0 answers

How to start a service with pm2?

I have a service which runs in background when I start it. As an example: pg_ctl -D /some/data start This starts postgres and exits leaving server running in background. PM2 thinks that the app exits and shows it as online for a couple of seconds…
Sergei Basharov
  • 51,276
  • 73
  • 200
  • 335
0
votes
1 answer

How to use PM2 Process Manager with SvelteKit

I am trying to manage my SvelteKit build with PM2 (Process Manager) — my problem is that I can't succesfully inject a .env-file using an ecosystem.config.cjs. My files currently look like this: .env.production PORT=3000 The only changing thing in…
SMEETT
  • 166
  • 1
  • 9
0
votes
1 answer

Should "pm2 save" need to be execute again after some script updates?

currently i'm using pm2 to manage my process, and i'm still new to this. I've search some docs but still not sure. About autostartup, what is the propper way to update my nodeJS script? right now, i just execute pm2 restart all after i update some…
aagns
  • 3
  • 2
0
votes
1 answer

Metric for number of requests in express app using pm2 cluster mode

I have an express application running with pm2 in cluster mode. We are monitoring with prometheus. I've been able to monitor the standard metrics of the cluster running a second process working as an exporter for prometheus. I need a metric with the…
Hans Poo
  • 804
  • 1
  • 8
  • 17
0
votes
1 answer

Strange issue starting a node application from another directory

I've got an MVC application using Nodejs / Express. If I start the app using PM2 within the directory EG. pm2 start my_app.js All is well. If I try to start it from another directory EG. pm2 start ../another_directory/my_app.js The app appears to…
Strontium_99
  • 1,771
  • 6
  • 31
  • 52
0
votes
2 answers

PM2 - Why am I getting EADDRINUSE address already in use message in index-out.log?

I'm running a NodeJS application on ubuntu LTS 20.4 managed by PM2. Application is running fine but when I check the logs I see lots of EADDRINUSE address already in use message. I started the server using the command sudo pm2 start index.js Error:…
Jugs
  • 43
  • 8
0
votes
1 answer

nginx is not redirecting custom ssl port to pm2 app

I have multiple node.js apps running (through pm2) on different ports (8000, 8200, 8300) of a single server using the http protocol. Now to enable https support I installed nginx and wrote config for redirecting incoming traffic on port 8200 to the…
m-ketan
  • 1,258
  • 2
  • 17
  • 23
0
votes
1 answer

npm: pm2-windows-startup not working properly

I want my application to automatically restart on Windows reboot. I am using the pm2-windows-startup package provided by the npm. But, I am having an issue. When I restart the remote server and enter the pm2 list command in the cmd, it shows my…
Package.JSON
  • 301
  • 5
  • 25
0
votes
1 answer

How to start a PM2 process using a virtual python environment with variables and disable pm2 logging

I am trying to start a python script in pm2 with a a variable. Without a variable, I would run: pm2 start --name myapp /home/user/myapp/start.py --interpreter ~/myapp_venv/bin/python3 The python command I would like to run is: python3…
Ben Doyle
  • 3
  • 2
0
votes
4 answers

Where do log files locate in pm2 in sudo mode

I'm new to PM2 and ubuntu-related issues. I'm running an app using sudo with the syntax sudo pm2 start app.js --time. However, when I tried to check the files in $HOME/.pm2/logs/app-error.log, I couldn't find any logs related to what I logged in the…
Lucas.Pheliny
  • 85
  • 1
  • 8
0
votes
0 answers

Nginx configuration for 2 apps on same domain, one static, one SSR

I have 2 apps. App1 is a ReactJS single page app and I want it as a homepage at www.mydomain.com App2 has a nodejs back-end exposing graphql APIs + a ReactJs front-end and I want this app's homepage to be rooted at www.mydomain.com/app2 Since app2…
Fabian
  • 229
  • 3
  • 8
0
votes
1 answer

How come my Discord bot (NodeJS) doesn't go online after a system reboot on a Raspberry Pi 4, with pm2?

I am trying to host a Discord bot on a Raspberry Pi. I have gotten everything to work and I have a bot running on it. I also made it so the bot restarts on a system reboot. The bot logs in perfectly. However, I tried adding another bot and again, I…
0
votes
1 answer

Pm2 trigger email if service down

I am running a php script to output the server, cronJobs, and processes. If I do pm2 stop server and run the script it shoots an email with details of which service is stopped, everything is working perfectly as if $errored comes in place. $errored…
Ammar
  • 1
  • 1
0
votes
2 answers

PM2 is catching errors before they reach 'uncaught Exception' in Node.js

Hey Guys, I am running a discordbot with Discord.js in Node.js. My goal is to run it via pm2 on a Linux Ubuntu Server. I want to build a cleanup process before exiting the program on uncaught Exception. However when I throw a sample error and run it…
Huetti
  • 1
  • 3