Skip to content

Commit

Permalink
refactor: drop gracefullreload
Browse files Browse the repository at this point in the history
  • Loading branch information
wallet77 committed Feb 28, 2018
1 parent d322dd0 commit bb57c76
Show file tree
Hide file tree
Showing 20 changed files with 8 additions and 229 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ $ pm2 reset [app-name] # Reset all counters
$ pm2 stop all # Stop all apps
$ pm2 stop 0 # Stop process with id 0
$ pm2 restart all # Restart all apps
$ pm2 gracefulReload all # Gracefully reload all apps in cluster mode
$ pm2 delete all # Kill and delete all apps
$ pm2 delete 0 # Delete app with id 0

Expand Down
11 changes: 1 addition & 10 deletions bin/pm2
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function checkCompletion(){
return data.short;
}), data);
// array containing commands after which process name should be listed
var cmdProcess = ['stop', 'restart', 'scale', 'reload', 'gracefulReload', 'delete', 'reset', 'pull', 'forward', 'backward', 'logs', 'describe', 'desc', 'show'];
var cmdProcess = ['stop', 'restart', 'scale', 'reload', 'delete', 'reset', 'pull', 'forward', 'backward', 'logs', 'describe', 'desc', 'show'];

if (cmdProcess.indexOf(data.prev) > -1) {
pm2.list(function(err, list){
Expand Down Expand Up @@ -390,15 +390,6 @@ commander.command('reload <name|all>')
pm2.reload(pm2_id, commander);
});

//
// Reload process(es)
//
commander.command('gracefulReload <name|all>')
.description('gracefully reload a process. Send a "shutdown" message to close all connections.')
.action(function(pm2_id) {
pm2.gracefulReload(pm2_id, commander);
});

commander.command('id <name>')
.description('get process id by name')
.action(function(name) {
Expand Down
2 changes: 1 addition & 1 deletion examples/misc-examples/graceful-exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Example of graceful exit
*
* $ pm2 gracefulReload all
* $ pm2 reload all
*/

process.on('message', function(msg) {
Expand Down
27 changes: 0 additions & 27 deletions examples/sourcemap-auto-resolve/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,33 +399,6 @@ API.prototype.update = function(cb) {
return false;
};

/**
* Graceful Reload an application
*
* @param {String} process_name Application Name or All
* @param {Object} opts Options
* @param {Function} cb Callback
*/
API.prototype.gracefulReload = function(process_name, opts, cb) {
var that = this;

if (typeof(opts) == "function") {
cb = opts;
opts = {};
}

//Common.printOut(conf.PREFIX_MSG_WARNING + chalk.bold.yellow('Warning gracefulReload will be soon deprecated'));
//Common.printOut(conf.PREFIX_MSG_WARNING + chalk.bold.yellow('Use http://pm2.keymetrics.io/docs/usage/signals-clean-restart/ instead'));

if (Common.isConfigFile(process_name))
that._startJson(process_name, commander, 'softReloadProcessId');
else {
if (opts && !opts.updateEnv)
Common.printOut(IMMUTABLE_MSG);
that._operate('softReloadProcessId', process_name, opts, cb);
}
};

/**
* Reload an application
*
Expand Down
27 changes: 0 additions & 27 deletions lib/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,33 +402,6 @@ class API {
return false;
}

/**
* Graceful Reload an application
*
* @param {String} process_name Application Name or All
* @param {Object} opts Options
* @param {Function} cb Callback
*/
gracefulReload (process_name, opts, cb) {
var that = this;

if (typeof(opts) == "function") {
cb = opts;
opts = {};
}

//Common.printOut(conf.PREFIX_MSG_WARNING + chalk.bold.yellow('Warning gracefulReload will be soon deprecated'));
//Common.printOut(conf.PREFIX_MSG_WARNING + chalk.bold.yellow('Use http://pm2.keymetrics.io/docs/usage/signals-clean-restart/ instead'));

if (Common.isConfigFile(process_name))
that._startJson(process_name, commander, 'softReloadProcessId');
else {
if (opts && !opts.updateEnv)
Common.printOut(IMMUTABLE_MSG);
that._operate('softReloadProcessId', process_name, opts, cb);
}
}

/**
* Reload an application
*
Expand Down
10 changes: 0 additions & 10 deletions lib/API/Version.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,6 @@ module.exports = function(CLI) {
this._pull({process_name: process_name, action: 'reload'}, cb);
};

/**
* CLI method for updating a repository
* @method pullAndGracefulReload
* @param {string} process_name name of processes to pull
* @return
*/
CLI.prototype.pullAndGracefulReload = function (process_name, cb) {
this._pull({process_name: process_name, action: 'gracefulReload'}, cb);
};

/**
* CLI method for updating a repository to a specific commit id
* @method pullCommitId
Expand Down
2 changes: 1 addition & 1 deletion lib/God/Reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function hardReload(God, id, wait_msg, cb) {
module.exports = function(God) {

/**
* GracefulReload
* Reload
* @method softReloadProcessId
* @param {} id
* @param {} cb
Expand Down
1 change: 0 additions & 1 deletion lib/Interactor/RemoteActions/Pm2Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ var Password = require('../Password.js');
var PM2_REMOTE_METHOD_ALLOWED = {
'restart' : {},
'reload' : {},
'gracefulReload' : {},
'reset' : {},
'scale' : {},

Expand Down
11 changes: 1 addition & 10 deletions test/bash/app-config-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,10 @@ $pm2 reload app-config-update/echo.js --node-args="--harmony"
$pm2 prettylist | grep "node_args: \[ '--harmony' \]"
spec "Should application have one node argument"

$pm2 gracefulReload app-config-update/echo.js --node-args="--harmony"
$pm2 prettylist | grep "node_args: \[ '--harmony' \]"
spec "Should application have two node arguments"

$pm2 prettylist | grep "node_args"
spec "Should have found parameter"
# Now set node-args to null
$pm2 gracefulReload app-config-update/echo.js --node-args=null
$pm2 reload app-config-update/echo.js --node-args=null
# Should not find node_args anymore
$pm2 prettylist | grep "node_args"
ispec "Should have deleted cli parameter when passing null"
Expand All @@ -74,8 +70,3 @@ $pm2 reload echo --name="new-name"
$pm2 reset all
$pm2 restart new-name
should 'should reload processes with new name' 'restart_time: 1' 1

$pm2 gracefulReload new-name --name="new-name-2"
$pm2 reset all
$pm2 restart new-name-2
should 'should graceful reload processes with new name' 'restart_time: 1' 1
35 changes: 0 additions & 35 deletions test/bash/gracefulReload.sh

This file was deleted.

28 changes: 0 additions & 28 deletions test/bash/gracefulReload2.sh

This file was deleted.

22 changes: 0 additions & 22 deletions test/bash/gracefulReload3.sh

This file was deleted.

7 changes: 1 addition & 6 deletions test/bash/json-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,13 @@ sleep 1
should 'should reload processes' 'online' 6
should 'should all script been restarted one time' 'restart_time: 2' 6

$pm2 gracefulReload all.json
sleep 1
should 'should graceful reload processes' 'online' 6
should 'should all script been restarted one time' 'restart_time: 3' 6

##
## Smart restart
##
$pm2 start all.json
sleep 1
should 'should smart restart processes' 'online' 6
should 'should all script been restarted one time' 'restart_time: 4' 6
should 'should all script been restarted one time' 'restart_time: 3' 6

$pm2 stop all.json
sleep 1
Expand Down
2 changes: 0 additions & 2 deletions test/bash/reload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ $pm2 restart delayed_exit.js
should 'should restart processes' 'restart_time: 1' 2
$pm2 reload delayed_exit.js
should 'should restart processes' 'restart_time: 2' 2
$pm2 gracefulReload delayed_exit.js
should 'should restart processes' 'restart_time: 3' 2
$pm2 kill

$pm2 start child.js -i 4
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/graceful-exit-no-listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Example of graceful exit that does not listen
*
* $ pm2 gracefulReload all
* $ pm2 reload all
*/

process.on('message', function(msg) {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/graceful-exit-send.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Example of graceful exit that does not listen but sends 'online'
*
* $ pm2 gracefulReload all
* $ pm2 reload all
*/

process.on('message', function(msg) {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/graceful-exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Example of graceful exit
*
* $ pm2 gracefulReload all
* $ pm2 reload all
*/

process.on('message', function(msg) {
Expand Down
24 changes: 0 additions & 24 deletions test/interface/remote.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,30 +145,6 @@ describe('REMOTE PM2 ACTIONS', function() {
});
});

it('should gracefulRELOAD', function(done) {
send_cmd.once('trigger:pm2:result', function(pck) {
/**
* Once remote command is finished...
*/

should(pck.ret.err).be.null();

pm2.list(function(err, ret) {
ret.forEach(function(proc) {
proc.pm2_env.restart_time.should.eql(3);
});
});

done();
});

send_cmd.emit('cmd', {
_type : 'trigger:pm2:action',
method_name : 'gracefulReload',
parameters : {name : 'child' }
});
});

it('should RESET metadata', function(done) {
send_cmd.once('trigger:pm2:result', function(pck) {
/**
Expand Down
6 changes: 0 additions & 6 deletions test/pm2_behavior_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ bash ./test/bash/right-exit-code.sh
spec "Verification exit code"
bash ./test/bash/log-reload.sh
spec "Log reload"
bash ./test/bash/gracefulReload.sh
spec "gracefulReload system 1"
bash ./test/bash/gracefulReload2.sh
spec "gracefulReload system 2"
bash ./test/bash/gracefulReload3.sh
spec "gracefulReload system 3"
bash ./test/bash/misc.sh
spec "MISC features"
bash ./test/bash/fork.sh
Expand Down
15 changes: 0 additions & 15 deletions test/programmatic/signals.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,6 @@ describe('Signal kill (+delayed)', function() {
});

});

it('should graceful reload script', function(done) {
setTimeout(function() {
pm2.list(function(err, list) {
list[0].pm2_env.status.should.eql('online');
list[0].pm2_env.restart_time.should.eql(2);
done();
});
}, 1500);

pm2.gracefulReload('delayed-sigint', function(err, app) {
//done(err);
});

});
});

describe('with 4000ms via kill_timeout (json/cli option)', function() {
Expand Down

0 comments on commit bb57c76

Please sign in to comment.