Skip to content

Commit

Permalink
When passenger-config restart-app is run interactively, if Passenge…
Browse files Browse the repository at this point in the history
…r is not serving any applications, then the command now prints an error message instead of showing a menu with only a "Cancel" option.
  • Loading branch information
FooBarWidget committed Mar 4, 2015
1 parent 6e63819 commit df34205
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Release 5.0.2
-------------

* When `passenger-config restart-app` is run interactively, if Passenger is not serving any applications, then the command now prints an error message instead of showing a menu with only a "Cancel" option.


Release 5.0.1
-------------

Expand Down
12 changes: 8 additions & 4 deletions lib/phusion_passenger/config/restart_app_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,16 @@ def query_group_names
def select_app_group_name_interactively
colors = PhusionPassenger::Utils::AnsiColors.new

choices = query_group_names
if choices.size == 1
# No running apps
abort_app_not_found "#{PROGRAM_NAME} is currently not serving any applications."
end

puts "Please select the application to restart."
puts colors.ansi_colorize("<gray>Tip: re-run this command with --help to learn how to automate it.</gray>")
puts colors.ansi_colorize("<dgray>If the menu doesn't display correctly, press '!'</dgray>")
puts

choices = query_group_names
menu = PhusionPassenger::Utils::TerminalChoiceMenu.new(choices, :single_choice)
begin
index, name = menu.query
Expand Down Expand Up @@ -205,7 +209,7 @@ def perform_restart
:method => restart_method)
response = @instance.http_request("agents.s/server_admin", request)
if response.code.to_i / 100 == 2
return REXML::Document.new(response.body)
response.body
else
STDERR.puts "*** An error occured while communicating with the #{PROGRAM_NAME} server:"
STDERR.puts response.body
Expand All @@ -228,7 +232,7 @@ def query_pool_xml
request.basic_auth("ro_admin", obtain_read_only_admin_password(@instance))
response = @instance.http_request("agents.s/server_admin", request)
if response.code.to_i / 100 == 2
return REXML::Document.new(response.body)
REXML::Document.new(response.body)
else
STDERR.puts "*** An error occured while querying the #{PROGRAM_NAME} server:"
STDERR.puts response.body
Expand Down

0 comments on commit df34205

Please sign in to comment.