From bb57c76d4191343925013d4353299092d80732c9 Mon Sep 17 00:00:00 2001 From: vince Date: Wed, 28 Feb 2018 18:39:40 +0100 Subject: [PATCH] refactor: drop gracefullreload --- README.md | 1 - bin/pm2 | 11 +------ examples/misc-examples/graceful-exit.js | 2 +- examples/sourcemap-auto-resolve/API.js | 27 ----------------- lib/API.js | 27 ----------------- lib/API/Version.js | 10 ------- lib/God/Reload.js | 2 +- lib/Interactor/RemoteActions/Pm2Actions.js | 1 - test/bash/app-config-update.sh | 11 +------ test/bash/gracefulReload.sh | 35 ---------------------- test/bash/gracefulReload2.sh | 28 ----------------- test/bash/gracefulReload3.sh | 22 -------------- test/bash/json-file.sh | 7 +---- test/bash/reload.sh | 2 -- test/fixtures/graceful-exit-no-listen.js | 2 +- test/fixtures/graceful-exit-send.js | 2 +- test/fixtures/graceful-exit.js | 2 +- test/interface/remote.mocha.js | 24 --------------- test/pm2_behavior_tests.sh | 6 ---- test/programmatic/signals.js | 15 ---------- 20 files changed, 8 insertions(+), 229 deletions(-) delete mode 100644 test/bash/gracefulReload.sh delete mode 100644 test/bash/gracefulReload2.sh delete mode 100644 test/bash/gracefulReload3.sh diff --git a/README.md b/README.md index 1ef3279ae..21a9dc853 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/pm2 b/bin/pm2 index 05072f4bc..809177b03 100755 --- a/bin/pm2 +++ b/bin/pm2 @@ -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){ @@ -390,15 +390,6 @@ commander.command('reload ') pm2.reload(pm2_id, commander); }); -// -// Reload process(es) -// -commander.command('gracefulReload ') - .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 ') .description('get process id by name') .action(function(name) { diff --git a/examples/misc-examples/graceful-exit.js b/examples/misc-examples/graceful-exit.js index df593d447..a35fc3e85 100644 --- a/examples/misc-examples/graceful-exit.js +++ b/examples/misc-examples/graceful-exit.js @@ -2,7 +2,7 @@ /* * Example of graceful exit * - * $ pm2 gracefulReload all + * $ pm2 reload all */ process.on('message', function(msg) { diff --git a/examples/sourcemap-auto-resolve/API.js b/examples/sourcemap-auto-resolve/API.js index ed62bdecb..544138794 100644 --- a/examples/sourcemap-auto-resolve/API.js +++ b/examples/sourcemap-auto-resolve/API.js @@ -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 * diff --git a/lib/API.js b/lib/API.js index d950d1b06..0296c2d31 100644 --- a/lib/API.js +++ b/lib/API.js @@ -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 * diff --git a/lib/API/Version.js b/lib/API/Version.js index 8f5bb93ba..a32de64f9 100644 --- a/lib/API/Version.js +++ b/lib/API/Version.js @@ -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 diff --git a/lib/God/Reload.js b/lib/God/Reload.js index d55cad1cc..5472f3b4e 100644 --- a/lib/God/Reload.js +++ b/lib/God/Reload.js @@ -174,7 +174,7 @@ function hardReload(God, id, wait_msg, cb) { module.exports = function(God) { /** - * GracefulReload + * Reload * @method softReloadProcessId * @param {} id * @param {} cb diff --git a/lib/Interactor/RemoteActions/Pm2Actions.js b/lib/Interactor/RemoteActions/Pm2Actions.js index a6de7c611..b5edd93bb 100644 --- a/lib/Interactor/RemoteActions/Pm2Actions.js +++ b/lib/Interactor/RemoteActions/Pm2Actions.js @@ -21,7 +21,6 @@ var Password = require('../Password.js'); var PM2_REMOTE_METHOD_ALLOWED = { 'restart' : {}, 'reload' : {}, - 'gracefulReload' : {}, 'reset' : {}, 'scale' : {}, diff --git a/test/bash/app-config-update.sh b/test/bash/app-config-update.sh index 8ef0a532c..1807110eb 100644 --- a/test/bash/app-config-update.sh +++ b/test/bash/app-config-update.sh @@ -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" @@ -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 diff --git a/test/bash/gracefulReload.sh b/test/bash/gracefulReload.sh deleted file mode 100644 index e7ed9fce5..000000000 --- a/test/bash/gracefulReload.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -SRC=$(cd $(dirname "$0"); pwd) -source "${SRC}/include.sh" - -cd $file_path - -echo "################## GRACEFUL RELOAD ###################" - -############### - -echo "Launching" -$pm2 start graceful-exit.js -i 4 --name="graceful" -o "grace.log" -e "grace-err.log" -should 'should start processes' 'online' 4 - -OUT_LOG=`$pm2 prettylist | grep -m 1 -E "pm_out_log_path:" | sed "s/.*'\([^']*\)',/\1/"` -cat /dev/null > $OUT_LOG - -#### Graceful reload all - -$pm2 gracefulReload all - -OUT=`grep "Finished closing connections" "$OUT_LOG" | wc -l` -[ $OUT -eq 1 ] || fail "Process not restarted gracefuly" -success "Process restarted gracefuly" - - -cat /dev/null > $OUT_LOG - -#### Graceful reload name -$pm2 gracefulReload graceful - -OUT=`grep "Finished closing connections" "$OUT_LOG" | wc -l` -[ $OUT -eq 1 ] || fail "Process not restarted gracefuly" -success "Process restarted gracefuly" diff --git a/test/bash/gracefulReload2.sh b/test/bash/gracefulReload2.sh deleted file mode 100644 index b7c25fdd4..000000000 --- a/test/bash/gracefulReload2.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -SRC=$(cd $(dirname "$0"); pwd) -source "${SRC}/include.sh" - -cd $file_path - -echo "################## GRACEFUL RELOAD 2 ###################" - -echo "Launching" -$pm2 start graceful-exit-no-listen.js -i 2 --name="graceful2" -o "grace2.log" -e "grace-err2.log" -should 'should start processes' 'online' 2 - -OUT_LOG=`$pm2 prettylist | grep -m 1 -E "pm_out_log_path:" | sed "s/.*'\([^']*\)',/\1/"` -cat /dev/null > $OUT_LOG - -#### Graceful reload name -$pm2 gracefulReload graceful2 - -echo "PATH: $OUT_LOG" - -TEXT=$(cat $OUT_LOG) - -echo "TEXT: $TEXT" - -OUT=`grep "Finished closing connections" "$OUT_LOG" | wc -l` -[ $OUT -eq 1 ] || fail "Non-listening process not restarted gracefuly" -success "Non-listening process restarted gracefuly" diff --git a/test/bash/gracefulReload3.sh b/test/bash/gracefulReload3.sh deleted file mode 100644 index 307d74f6b..000000000 --- a/test/bash/gracefulReload3.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -SRC=$(cd $(dirname "$0"); pwd) -source "${SRC}/include.sh" - -cd $file_path - -echo "################## GRACEFUL RELOAD 3 ###################" - -echo "Launching" -$pm2 start graceful-exit-send.js -i 2 --name="graceful3" -o "grace3.log" -e "grace-err3.log" -should 'should start processes' 'online' 2 - -OUT_LOG=`$pm2 prettylist | grep -m 1 -E "pm_out_log_path:" | sed "s/.*'\([^']*\)',/\1/"` -cat /dev/null > $OUT_LOG - -#### Graceful reload name -$pm2 gracefulReload graceful3 - -OUT=`grep "Finished closing connections" "$OUT_LOG" | wc -l` -[ $OUT -eq 1 ] || fail "Process that sends 'online' not restarted gracefuly" -success "Process that sends 'online' restarted gracefuly" diff --git a/test/bash/json-file.sh b/test/bash/json-file.sh index 50c3ff352..08ce5543b 100644 --- a/test/bash/json-file.sh +++ b/test/bash/json-file.sh @@ -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 diff --git a/test/bash/reload.sh b/test/bash/reload.sh index d659a1b6c..88ad94165 100644 --- a/test/bash/reload.sh +++ b/test/bash/reload.sh @@ -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 diff --git a/test/fixtures/graceful-exit-no-listen.js b/test/fixtures/graceful-exit-no-listen.js index 37cfba2dc..814d3845c 100644 --- a/test/fixtures/graceful-exit-no-listen.js +++ b/test/fixtures/graceful-exit-no-listen.js @@ -2,7 +2,7 @@ /* * Example of graceful exit that does not listen * - * $ pm2 gracefulReload all + * $ pm2 reload all */ process.on('message', function(msg) { diff --git a/test/fixtures/graceful-exit-send.js b/test/fixtures/graceful-exit-send.js index 7142c3f5d..94d461f00 100644 --- a/test/fixtures/graceful-exit-send.js +++ b/test/fixtures/graceful-exit-send.js @@ -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) { diff --git a/test/fixtures/graceful-exit.js b/test/fixtures/graceful-exit.js index 43e8212a9..5b1461a18 100644 --- a/test/fixtures/graceful-exit.js +++ b/test/fixtures/graceful-exit.js @@ -2,7 +2,7 @@ /* * Example of graceful exit * - * $ pm2 gracefulReload all + * $ pm2 reload all */ process.on('message', function(msg) { diff --git a/test/interface/remote.mocha.js b/test/interface/remote.mocha.js index d1ded5a12..87adbcd41 100644 --- a/test/interface/remote.mocha.js +++ b/test/interface/remote.mocha.js @@ -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) { /** diff --git a/test/pm2_behavior_tests.sh b/test/pm2_behavior_tests.sh index 6b1fa6306..9d212a11d 100644 --- a/test/pm2_behavior_tests.sh +++ b/test/pm2_behavior_tests.sh @@ -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 diff --git a/test/programmatic/signals.js b/test/programmatic/signals.js index 6c9c93b30..fad65206e 100644 --- a/test/programmatic/signals.js +++ b/test/programmatic/signals.js @@ -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() {