Reputation: 35
I was wondering if it was possible to get process metadata using pm2 inside my node application.
Upvotes: 0
Views: 369
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