RTVBasic
RTVBasic

Reputation: 35

Is it possible to get the process metadata from PM2?

I was wondering if it was possible to get process metadata using pm2 inside my node application.

enter image description here

Upvotes: 0

Views: 369

Answers (1)

Adiii
Adiii

Reputation: 59896

Yes, you can get any information from pm2 inside your app. below will return all running process list. For further details, you can check pm2-api

var pm2 = require('pm2');
app.use('/all_process_list', function(req,res){

  pm2.connect(function(err) {
    if (err) {
      console.error(err);
      process.exit(2);
    }
    pm2.list(function(err, processDescriptionList) {
      console.log(processDescriptionList)
      res.json ({process_list:processDescriptionList})
      pm2.disconnect();   // Disconnects from PM2

    });
  });   
});

Upvotes: 1

Related Questions