From 101ac1e390394329a496477876b6530c8c951428 Mon Sep 17 00:00:00 2001 From: Nick Muerdter Date: Sun, 19 Feb 2017 08:58:04 -0700 Subject: [PATCH] Remove legacy stop/status logic for upgrading from v0.8. This removes the extra logic for checking the status and stopping the old v0.8 and prior versions of API Umbrella (the old NodeJS stack). We've stopped testing the direct upgrade path from these older package versions, and they seem old enough that this is hopefully no longer necessary. --- build/package_dependencies.sh | 12 +++--- src/api-umbrella/cli/status.lua | 33 --------------- src/api-umbrella/cli/stop.lua | 75 --------------------------------- 3 files changed, 6 insertions(+), 114 deletions(-) diff --git a/build/package_dependencies.sh b/build/package_dependencies.sh index eee36648f..3eafa0707 100644 --- a/build/package_dependencies.sh +++ b/build/package_dependencies.sh @@ -49,9 +49,6 @@ if [ -f /etc/redhat-release ]; then # For pstree used in reopen-logs command. psmisc - - # For pkill/pgrep used for legacy status/stop commands. - $procps_package ) hadoop_analytics_package_dependencies=( java-1.8.0-openjdk-headless @@ -106,6 +103,9 @@ if [ -f /etc/redhat-release ]; then # Fonts for Capybara screenshots. urw-fonts + + # For pkill/pgrep used for process tests. + $procps_package ) elif [ -f /etc/debian_version ]; then libffi_version=6 @@ -150,9 +150,6 @@ elif [ -f /etc/debian_version ]; then # For pstree used in reopen-logs command. psmisc - - # For pkill/pgrep used for legacy status/stop commands. - procps ) hadoop_analytics_package_dependencies=( openjdk-$openjdk_version-jre-headless @@ -207,6 +204,9 @@ elif [ -f /etc/debian_version ]; then # Fonts for Capybara screenshots. gsfonts + + # For pkill/pgrep used for process tests. + procps ) if [[ "$ID" == "debian" && "$VERSION_ID" == "8" ]] || [[ "$ID" == "ubuntu" && "$VERSION_ID" == "16.04" ]]; then diff --git a/src/api-umbrella/cli/status.lua b/src/api-umbrella/cli/status.lua index 401dd25dd..3a5014452 100644 --- a/src/api-umbrella/cli/status.lua +++ b/src/api-umbrella/cli/status.lua @@ -2,33 +2,6 @@ local file = require "pl.file" local path = require "pl.path" local read_config = require "api-umbrella.cli.read_config" local run_command = require "api-umbrella.utils.run_command" -local stringx = require "pl.stringx" - --- Get the status of the legacy nodejs version (v0.8 and before) of the app. --- --- This is present here so that we can cleanly perform package upgrades from --- the legacy version and restart after the upgrade. At some point we can --- probably remove this (once we no longer need to support upgrades from v0.8). -local function legacy_status() - -- Only perform the legacy status if it appears as though it might be - -- present. - if not path.exists("/opt/api-umbrella/var/run/forever") then - return nil - end - - local _, output, err = run_command("pgrep -f '^/opt/api-umbrella/embedded/bin/node.*api-umbrella run'") - if err and output ~= "" then - return nil - elseif err and output == "" then - -- If the legacy process isn't running, then go ahead and remove the legacy - -- directory so we know we don't need to do this again for an upgraded box. - run_command("rm -rf /opt/api-umbrella/var/run/forever") - return nil - end - - local pid = tonumber(stringx.strip(output)) - return true, pid -end local function perp_status(config) local running = false @@ -56,11 +29,5 @@ end return function() local config = read_config() - - local legacy_running, legacy_pid = legacy_status() - if legacy_running ~= nil then - return legacy_running, legacy_pid - end - return perp_status(config) end diff --git a/src/api-umbrella/cli/stop.lua b/src/api-umbrella/cli/stop.lua index bc4820ce3..a6ef95c99 100644 --- a/src/api-umbrella/cli/stop.lua +++ b/src/api-umbrella/cli/stop.lua @@ -1,77 +1,7 @@ -local path = require "pl.path" local run_command = require "api-umbrella.utils.run_command" local status = require "api-umbrella.cli.status" -local stringx = require "pl.stringx" local time = require "posix.time" --- Stop the legacy nodejs version (v0.8 and before) of the app. --- --- This is present here so that we can cleanly perform package upgrades from --- the legacy version and restart after the upgrade. At some point we can --- probably remove this (once we no longer need to support upgrades from v0.8). -local function stop_legacy() - -- Only perform the legacy stop if it appears as though it might be present. - if not path.exists("/opt/api-umbrella/var/run/forever") then - return true - end - - local running, _ = status() - if not running then - print "api-umbrella is already stopped" - return true - end - - -- Stop the various processes tied to the old service. - local _, output, err = run_command("pkill -TERM -f '^/opt/api-umbrella/embedded/bin/node.*forever/bin/monitor.*api-umbrella'") - if err and output ~= "" then - return false, err - end - - _, output, err = run_command("pkill -TERM -f '^/opt/api-umbrella/embedded/bin/node.*api-umbrella run'") - if err and output ~= "" then - return false, err - end - - _, output, err = run_command("pgrep -f '^/opt/api-umbrella/embedded/bin/python.*supervisord.*api-umbrella'") - if err and output ~= "" then - return false, err - elseif err and output == "" then - return true - end - - local supervisord_pid = stringx.strip(output) - _, _, err = run_command("kill -s TERM " .. supervisord_pid) - if err then - return false, err - end - - -- Wait until the old processes have completely shut down. - local stopped = false - for _ = 1, 200 do - local supervisord_status = run_command("pgrep -f '/opt/api-umbrella/embedded/bin/python.*supervisord.*api-umbrella'") - if supervisord_status == 0 then - -- Sleep for 0.2 seconds. - time.nanosleep({ tv_sec = 0, tv_nsec = 200000000 }) - else - stopped = true - break - end - end - - if not stopped then - return false, "failed to stop" - end - - -- Remove the legacy directory so we know we don't need to do this again for - -- an upgraded box. - _, _, err = run_command("rm -rf /opt/api-umbrella/var/run/forever") - if err then - return false, err - end - - return true -end - local function stop_perp() local running, pid = status() if not running then @@ -109,10 +39,5 @@ local function stop_perp() end return function() - local ok, err = stop_legacy() - if not ok then - return ok, err - end - return stop_perp() end