Skip to content

Commit

Permalink
Merge pull request #3716 from Unitech/io_conf
Browse files Browse the repository at this point in the history
Io conf
  • Loading branch information
wallet77 committed Jun 18, 2018
2 parents d8cff0d + ba2ee3b commit 0bc000b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,8 @@ class API {

// Here we pick only the field we want from the CLI when starting a JSON
appConf.forEach(function(app) {
if (!app.env) { app.env = {}; }
app.env.io = app.io;
// --only <app>
if (opts.only && opts.only != app.name)
return false;
Expand Down Expand Up @@ -911,6 +913,7 @@ class API {
* and act on them depending on action
*/
async.eachLimit(Object.keys(proc_list), conf.CONCURRENT_ACTIONS, function(proc_name, next) {

// Skip app name (--only option)
if (apps_name.indexOf(proc_name) == -1)
return next();
Expand Down
4 changes: 4 additions & 0 deletions lib/API/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,5 +304,9 @@
},
"write": {
"type": "boolean"
},
"io": {
"type": "object",
"docDescription": "Specify apm values and configuration"
}
}
18 changes: 16 additions & 2 deletions lib/ProcessUtils.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
'use strict'

module.exports = {
injectModules: function() {
if (process.env.pmx !== 'false') {
const pmx = require('@pm2/io');
pmx.init({

let conf = {};

if (process.env.io) {
const io = JSON.parse(process.env.io);
conf = io.conf ? io.conf : conf;
}

let defaultConf = {
transactions: (process.env.trace === 'true' || process.env.deep_monitoring === 'true') || false,
http: process.env.km_link === 'true' || false,
v8: process.env.v8 === 'true' || process.env.deep_monitoring === 'true' || false,
event_loop_dump: process.env.event_loop_inspector === 'true' || process.env.deep_monitoring === 'true' || false,
deep_metrics: process.env.deep_monitoring === 'true' || false
});
};

Object.assign(conf, defaultConf);

pmx.init(conf);

if(require('semver').satisfies(process.versions.node, '>= 8.0.0')) {
var url = '';
Expand Down

0 comments on commit 0bc000b

Please sign in to comment.