简体   繁体   中英

PM2 restarting keystonejs app repetitively

I am using throng to cluster my keystonejs application, which seems to work fine but when I run

const throng = require("throng"),
      dotenv = require('dotenv');

(function usedotenv() {
    try {
        dotenv.config();
    }
    catch (e) {
        console.error(e);
    }
}());

throng({
  workers: process.env.WEB_CONCURRENCY || 1,
  grace: 4000,
  master() {
    console.log("Starting master node");
  },
  start(id) {
    console.log("Starting worker node "+id);
    require("./keystone");
  }
});

using pm2 start index

│ App name │ id │ mode    │ pid   │ status  │ restart │ uptime │ memory │ watching │
├──────────┼────┼─────────┼───────┼─────────┼─────────┼────────┼────────┼──────────┤
│ index    │ 0  │ cluster │ 11964 │ online  │ 29      │ 2s     │ 0 B    │ disabled │
│ index    │ 1  │ cluster │ 6260  │ online  │ 12      │ 2s     │ 0 B    │ disabled │
│ index    │ 2  │ cluster │ 7920  │ online  │ 12      │ 2s     │ 0 B    │ disabled │
│ index    │ 3  │ cluster │ 5260  │ online  │ 12      │ 1s     │ 0 B    │ disabled │
│ index    │ 4  │ cluster │ 15688 │ online  │ 21      │ 1s     │ 0 B    │ disabled │
│ index    │ 5  │ cluster │ 17204 │ online  │ 15      │ 1s     │ 0 B    │ disabled │
│ index    │ 6  │ cluster │ 15576 │ online  │ 22      │ 1s     │ 0 B    │ disabled │
│ index    │ 7  │ cluster │ 6012  │ online  │ 20      │ 1s     │ 0 B    │ disabled │
│ index    │ 8  │ cluster │ 10768 │ online  │ 32      │ 1s     │ 0 B    │ disabled │
│ index    │ 9  │ cluster │ 9460  │ online  │ 14      │ 0s     │ 0 B    │ disabled │
│ index    │ 10 │ cluster │ 16968 │ online  │ 32      │ 0s     │ 0 B    │ disabled │
│ index    │ 11 │ cluster │ 12688 │ online  │ 23      │ 0s     │ 0 B    │ disabled │

The website works fine, but pm2 keeps restarting the apps because they're not using any memory: [PM2][WORKER] Process 0 restarted because it uses 0 memory and has ONLINE status

How do I keep pm2 from restarting my apps?

It looks like all of your processes are named the same "index". If you use

pm2 start 4

for example to start just the the one process does it stop the restarting of all process's?

I am just wondering if using the id to start it will allow it to identify just the single index, instead of all of the processes named index

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM