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
7
votes
3 answers

Winston is not writing logs to files

I made two transports for errors and warnings in Winston that supposedly writes to files. The existing transport for console logging works fine, and I did check pm2 logs and saw the logs, but the transports for files are not saving anyting. 'use…
Bargain23
  • 1,863
  • 3
  • 29
  • 50
7
votes
1 answer

Start nodejs app that use cross-env with pm2

I'm trying to start my nodejs app, the default cmd is the following : pm2 start app.js I can't do that because I use cross-env and the script as below: "start": cross-env DOTENV_FILE=.env node build/app.js So npm run start will launch the script…
An-droid
  • 6,433
  • 9
  • 48
  • 93
7
votes
1 answer

How to restart a PM2 process with process name instead of process id?

When we are running multiple node services in a single machine, its becoming hard to restart one service with id as id is a sequence number allocated in order by PM2. So instead using the id is it possible to restart the process using process name?…
karthikdivi
  • 3,466
  • 5
  • 27
  • 46
7
votes
2 answers

PM2 Logrotate keeps generating new logs

I have following settings set for PM2 Logrotate: rotateInterval= * * 23 * * * max_size= 100MB I want to rotate the logs every 23 hours and/or keep max 100MB log files. But for some odd reason, the PM2 Logrotate keeps rotating / creating new log…
Almir
  • 167
  • 1
  • 2
  • 6
7
votes
2 answers

How to run nuxt.js in real service?

I used vue-cli in vue init nuxt/express myProject and, npm run dev developed. but, npm run build after, was created dist file. How i can run in real service in pm2? (I will use ubuntu in AWS EC.)
hyeokluv
  • 377
  • 2
  • 8
  • 18
7
votes
2 answers

I can't find the process id

I have PM2 on a GoDaddy Ubuntu cloud server. pm2 list shows as follows: Is the fourth column the process id? Every one seems to be 0. Is there something wrong with my installation?
Old Geezer
  • 14,854
  • 31
  • 111
  • 198
7
votes
2 answers

PM2 not taking the latest version of nodejs installed

Previously, I had node version v0.10.46 installed on my ec2 server. For a recent project, I decided to give pm2 a try and installed pm2 using npm install pm2 -g. But, pm2 start index.js errored out since the project was using some ES6 syntax with…
A.I
  • 1,438
  • 2
  • 16
  • 18
7
votes
0 answers

PM2 dump vs ecosystem.json

I am configuring production infrastructure for node.js with pm2 and I am stuck with the relation between ecosystem.json file and pm2 save command that writes some sort of dump file. As far as I understood the contents of that dump file will be used…
Juriy
  • 5,009
  • 8
  • 37
  • 52
7
votes
4 answers

bash: pm2: command not found

I can't run pm2 on ubuntu box. I'm not sure what's the problem. The pm2 is installed globally. npm list -g --depth=0 /opt/nodejs/lib ├── forever@0.15.3 ├── node-gyp@3.4.0 ├── npm@2.15.9 ├── pm2@2.1.5 ├── userdown@0.2.1 └── wait-for-mongo@0.2.0 But…
Kamil
  • 321
  • 1
  • 2
  • 10
7
votes
1 answer

How to view pm2 command line arguments passed to Node.js at startup?

As a server administrator, I would like to view the command line arguments that a Node.js service was started with using pm2. (The ones that Node.js uses via process.argv) The command pm2 show my-service-name gives information around that service…
Lance
  • 165
  • 1
  • 3
  • 12
7
votes
1 answer

Monitor detached child processes with pm2

I have a pretty data heavy Node application. Besides common things like file uploading, the app also spawns detached (long running) child processes. For an example, consider a user uploads a file and the detached process triggers a native tool…
benjist
  • 2,740
  • 3
  • 31
  • 58
7
votes
1 answer

PM2 environment variables caching

I am running PM2 on Ubuntu 16.04 and it seems that environment variables are being cached somehow. Is there an way of seeing which environment variables PM2 are using. The environment variables it can somehow see are not available in my terminal…
André Vermeulen
  • 1,774
  • 4
  • 17
  • 26
7
votes
1 answer

Running Node as a service with PM2 - connection refused

I am following this tutorial for setting up a node project on a Digital Ocean Ubuntu distribution. systemctl status pm2 shows the service is online: App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching server │ 1 │…
rurp
  • 1,376
  • 2
  • 14
  • 22
7
votes
4 answers

How to force pm2 to restart after a specific amount of time?

I am using PM2 to keep my node.js apps running. Is there any way to have PM2 restart my app every 1 hour?
faressoft
  • 19,053
  • 44
  • 104
  • 146
7
votes
1 answer

Sending data to PM2 process using programatic API

I'm trying to send data from a my main app to a child process. I've tried a few different alternatives but I'm currently stuck. Advice or pointers is very much appreciated. I'm following the documentation at…
Fredrik Silfver
  • 286
  • 2
  • 7