Skip to content

Commit

Permalink
disable autodump Unitech#4763
Browse files Browse the repository at this point in the history
  • Loading branch information
Unitech committed Jun 29, 2020
1 parent a0a6c98 commit e790d82
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 32 deletions.
93 changes: 93 additions & 0 deletions examples/test-all-keymetrics-features/test-threshold.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

var axm = require('@pm2/io');


var users = 55
var battery = 80

var door = 0
var door_2 = 0

axm.action('tozero', function(reply) {
door = 0
reply({ok:true});
});


axm.action('toone', function(reply) {
door = 1
reply({ok:true});
});

axm.metric({
name : 'door',
value : function() {
return door
}
});


axm.action('tofalse', function(reply) {
door_2 = false
reply({ok:true});
});


axm.action('totrue', function(reply) {
door_2 = true
reply({ok:true});
});

axm.metric({
name : 'door2',
value : function() {
return door_2
}
});


axm.action('setval', function(reply) {
users = 50
reply(process.env);
});

axm.action('setbatterylow', function(reply) {
battery = 10
reply();
});

axm.action('sayHello', function(reply) {
reply({
msg : 'Yes hello and so? Xie Xie'
});
});

axm.metric({
name : 'random',
value : function() {
return Math.floor((Math.random() * 100) + 1);;
}
});


axm.metric({
name : 'Realtime user',
value : function() {
return users;
}
});


axm.metric({
name : 'neewmetric',
value : function() {
return 1;
}
});

axm.metric({
name : 'battery',
value : function() {
return battery;
}
});
32 changes: 8 additions & 24 deletions lib/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,12 @@ class API {

if (Common.isConfigFile(cmd) || (typeof(cmd) === 'object')) {
that._startJson(cmd, opts, 'restartProcessId', (err, procs) => {
that.autodump(() => {
return cb ? cb(err, procs) : this.speedList()
})
return cb ? cb(err, procs) : this.speedList()
})
}
else {
that._startScript(cmd, opts, (err, procs) => {
that.autodump(() => {
return cb ? cb(err, procs) : this.speedList()
})
return cb ? cb(err, procs) : this.speedList()
})
}
}
Expand Down Expand Up @@ -548,21 +544,15 @@ class API {

if (jsonVia == 'pipe')
return that.actionFromJson('deleteProcessId', process_name, commander, 'pipe', (err, procs) => {
that.autodump(() => {
return cb ? cb(err, procs) : this.speedList()
})
return cb ? cb(err, procs) : this.speedList()
});
if (Common.isConfigFile(process_name))
return that.actionFromJson('deleteProcessId', process_name, commander, 'file', (err, procs) => {
that.autodump(() => {
return cb ? cb(err, procs) : this.speedList()
})
return cb ? cb(err, procs) : this.speedList()
});
else {
that._operate('deleteProcessId', process_name, (err, procs) => {
that.autodump(() => {
return cb ? cb(err, procs) : this.speedList()
})
return cb ? cb(err, procs) : this.speedList()
});
}
}
Expand All @@ -585,23 +575,17 @@ class API {
process.stdin.on('data', function (param) {
process.stdin.pause();
that.actionFromJson('stopProcessId', param, commander, 'pipe', (err, procs) => {
that.autodump(() => {
return cb ? cb(err, procs) : this.speedList()
})
return cb ? cb(err, procs) : this.speedList()
})
});
}
else if (Common.isConfigFile(process_name))
that.actionFromJson('stopProcessId', process_name, commander, 'file', (err, procs) => {
that.autodump(() => {
return cb ? cb(err, procs) : this.speedList()
})
return cb ? cb(err, procs) : this.speedList()
});
else
that._operate('stopProcessId', process_name, (err, procs) => {
that.autodump(() => {
return cb ? cb(err, procs) : this.speedList()
})
return cb ? cb(err, procs) : this.speedList()
});
}

Expand Down
8 changes: 2 additions & 6 deletions lib/API/Startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,10 @@ module.exports = function(CLI) {
};

/**
* AutoDump after pm2.start, pm2.delete, pm2.stop actions
* if $ pm2 set pm2:autodump false
* this will desactivate this behavior
* DISABLED FEATURE
* KEEPING METHOD FOR BACKWARD COMPAT
*/
CLI.prototype.autodump = function(cb) {
if (this.pm2_configuration.autodump == true ||
this.pm2_configuration.autodump == "true")
return this.dump(true, cb)
return cb()
}

Expand Down
2 changes: 1 addition & 1 deletion lib/API/UX/pm2-ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function checkIfProcessAreDumped(list) {
Common.warn(`Current process list running is not in sync with saved list. ${chalk.italic(diff.join(' '))} differs. Type 'pm2 save' to synchronize.`)
}
else if (apps_dumped.length != apps_running.length) {
Common.warn(`Current process list running is not in sync with saved list. Type 'pm2 save' to synchronize or enable autosync via 'pm2 set pm2:autodump true'`)
Common.warn(`Current process list running is not in sync with saved list. Type 'pm2 save' to synchronize'`)
}
} catch(e) {
}
Expand Down
2 changes: 1 addition & 1 deletion test/programmatic/resurect_state.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var fs = require('fs');
var cst = require('../../constants.js');
var Configuration = require('../../lib/Configuration.js');

describe('Keep state on pm2 update', function() {
describe.skip('Keep state on pm2 update', function() {
var pm2

before((done) => {
Expand Down

0 comments on commit e790d82

Please sign in to comment.