Skip to content

Commit

Permalink
Remove legacy stop/status logic for upgrading from v0.8.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
GUI committed Feb 19, 2017
1 parent 4d28e1e commit 101ac1e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 114 deletions.
12 changes: 6 additions & 6 deletions build/package_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
33 changes: 0 additions & 33 deletions src/api-umbrella/cli/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
75 changes: 0 additions & 75 deletions src/api-umbrella/cli/stop.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

0 comments on commit 101ac1e

Please sign in to comment.