From fdf7b09ab84b2516cdbf97212827f7a5fcb707f2 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Mon, 18 Jun 2012 15:08:58 -0400 Subject: [PATCH] Bug 825766 - Catch any interrupts that have escaped all command execution --- express/bin/rhc | 96 +++++++++++++++++++++++---------------------- express/bin/rhc-app | 24 ++++++------ 2 files changed, 62 insertions(+), 58 deletions(-) diff --git a/express/bin/rhc b/express/bin/rhc index 876d5070f..207070e24 100755 --- a/express/bin/rhc +++ b/express/bin/rhc @@ -41,55 +41,59 @@ def run_setup_wizard_if_needed default_setup_wizard unless ARGV.include?('--noprompt') end -case ARGV[0] -when "domain" - run_setup_wizard_if_needed - system("rhc-domain #{get_args} 2>&1") - retcode = $?.exitstatus -when "app" - run_setup_wizard_if_needed - system("rhc-app #{get_args} 2>&1") - retcode = $?.exitstatus -when "sshkey" - run_setup_wizard_if_needed - system("rhc-sshkey #{get_args} 2>&1") - retcode = $?.exitstatus -when "port-forward" - run_setup_wizard_if_needed - system("rhc-port-forward #{get_args} 2>&1") - retcode = $?.exitstatus -when "server" - run_setup_wizard_if_needed - begin - require 'rhc/cli' - RHC::CLI.start(ARGV) +begin + case ARGV[0] + when "domain" + run_setup_wizard_if_needed + system("rhc-domain #{get_args} 2>&1") + retcode = $?.exitstatus + when "app" + run_setup_wizard_if_needed + system("rhc-app #{get_args} 2>&1") + retcode = $?.exitstatus + when "sshkey" + run_setup_wizard_if_needed + system("rhc-sshkey #{get_args} 2>&1") + retcode = $?.exitstatus + when "port-forward" + run_setup_wizard_if_needed + system("rhc-port-forward #{get_args} 2>&1") + retcode = $?.exitstatus + when "server" + run_setup_wizard_if_needed + begin + require 'rhc/cli' + RHC::CLI.start(ARGV) + retcode = 0 + rescue SystemExit => e + retcode = e.status + end + when "setup" + if ARGV.include?('--help') or ARGV.include?('-h') or ARGV.include?('help') + puts "Usage: rhc setup" + puts "Runs the setup wizard to configure your account" + exit 0 + end + + w = RHC::RerunWizard.new(RHC::Config.local_config_path) + success = w.run retcode = 0 - rescue SystemExit => e - retcode = e.status - end -when "setup" - if ARGV.include?('--help') or ARGV.include?('-h') or ARGV.include?('help') - puts "Usage: rhc setup" - puts "Runs the setup wizard to configure your account" - exit 0 + retcode = 1 unless success + when "-h", "--help", "help", nil + p_usage 0 + else + puts "Invalid rhc command: #{ARGV[0]}" + p_usage end - w = RHC::RerunWizard.new(RHC::Config.local_config_path) - success = w.run - retcode = 0 - retcode = 1 unless success -when "-h", "--help", "help", nil - p_usage 0 -else - puts "Invalid rhc command: #{ARGV[0]}" - p_usage -end + if retcode == nil + retcode = 1 -if retcode == nil - retcode = 1 + # return codes for uncaught signals are 128 + the signal code + retcode = 128 + $?.termsig if $?.signaled? and !$?.termsig.nil? + end - # return codes for uncaught signals are 128 + the signal code - retcode = 128 + $?.termsig if $?.signaled? and !$?.termsig.nil? + exit retcode +rescue Interrupt + exit 128 + 2 #INT end - -exit retcode diff --git a/express/bin/rhc-app b/express/bin/rhc-app index 6b7be18c1..35b9a84b2 100755 --- a/express/bin/rhc-app +++ b/express/bin/rhc-app @@ -17,10 +17,10 @@ Usage: rhc app ( | cartridge | --help) [] Create and manage an OpenShift application. List of commands - create Bind a registered rhcloud user to a domain in rhcloud. + create Create a new application on OpenShift show Display information about a user - start Starts the application (includes embedded) - stop Stops the application (includes embedded) + start Starts the application (includes all cartridges) + stop Stops the application (includes all cartridges) force-stop Stops all application processes restart Restart the application reload Reloads application configuration @@ -32,17 +32,17 @@ List of commands threaddump Trigger a thread dump for jbossas, jbosseap, and ruby applications tail Tail the logs of an application snapshot [save|restore] Saves/Restores an application snapshot to/from a tarball at the location specified using --filepath (default: ./$APPNAME.tar.gz) - cartridge Manage an embedded cartridge + cartridge Manage a cartridge runningin this application List of cartridge actions list List of supported embedded cartridges - add Add an embedded application - remove Remove an embedded application - stop Stop the embedded application - start Start the embedded application - restart Restart the embedded application - status Returns embedded application status - reload Reloads embedded application configuration + add Add a cartridge to this application + remove Remove a cartridge from this application + stop Stop a cartridge + start Start a cartridge + restart Restart a cartridge + status Returns cartridge status + reload Reloads cartridge configuration List of arguments -l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin}) @@ -63,7 +63,7 @@ List of arguments --alias alias Specify server alias (when using add/remove-alias) --config path Path of alternate config file --timeout # Timeout, in seconds, for the session - --enable-jenkins [name] Indicates to create a Jenkins application (if not already available) and embed the Jenkins client into this application. The default name will be 'jenkins' if not specified. Note that --no-dns is ignored for the creation of the Jenkins application. + --enable-jenkins [name] Enables builds for your application with Jenkins. You may optionally specify the name of the Jenkins application that is created (default: 'jenkins'). Note that --no-dns is ignored for the creation of the Jenkins application. USAGE exit exit_code end