argument :additional_cartridges, "A list of other cartridges such as databases you wish to add. Cartridges can also be added later using 'rhc cartridge add'", [], :arg_type => :list
# File lib/rhc/commands/app.rb, line 27 def create(name, cartridges) cartridge = check_cartridges(cartridges).first options.default :dns => true, :git => true header "Creating application '#{name}'" paragraph do table({"Namespace:" => options.namespace, "Cartridge:" => cartridge, "Gear Size:" => options.gear_size || "default", "Scaling:" => options.scaling ? "yes" : "no", } ).each { |s| say " #{s}" } end raise ArgumentError, "You have named both your main application and your Jenkins application '#{name}'. In order to continue you'll need to specify a different name with --enable-jenkins or choose a different application name." if jenkins_app_name == name && enable_jenkins? rest_app, rest_domain = nil raise RHC::DomainNotFoundException.new("No domains found. Please create a domain with 'rhc domain create <namespace>' before creating applications.") if rest_client.domains.empty? rest_domain = rest_client.find_domain(options.namespace) # check to make sure the right options are set for enabling jenkins jenkins_rest_app = check_jenkins(name, rest_domain) if enable_jenkins? # create the main app rest_app = create_app(name, cartridge, rest_domain, options.gear_size, options.scaling) # create a jenkins app if not available # don't error out if there are issues, setup warnings instead begin jenkins_rest_app = setup_jenkins_app(rest_domain) if enable_jenkins? and jenkins_rest_app.nil? rescue Exception => e add_issue("Jenkins failed to install - #{e}", "Installing jenkins and jenkins-client", "rhc app create jenkins", "rhc cartridge add jenkins-client -a #{rest_app.name}") end if jenkins_rest_app success, attempts, exit_code, exit_message = false, 1, 157, nil while (!success && exit_code == 157 && attempts < MAX_RETRIES) begin setup_jenkins_client(rest_app) success = true rescue RHC::Rest::ServerErrorException => e if (e.code == 157) # error downloading Jenkins /jnlpJars/jenkins-cli.jar attempts += 1 debug "Jenkins server could not be contacted, sleep and then retry: attempt #{attempts}\n #{e.message}" Kernel.sleep(10) end exit_code = e.code exit_message = e.message rescue Exception => e # timeout and other exceptions exit_code = 1 exit_message = e.message end end add_issue("Jenkins client failed to install - #{exit_message}", "Install the jenkins client", "rhc cartridge add jenkins-client -a #{rest_app.name}") if !success end if options.dns say "Your application's domain name is being propagated worldwide (this might take a minute)..." unless dns_propagated? rest_app.host add_issue("We were unable to lookup your hostname (#{rest_app.host}) in a reasonable amount of time and can not clone your application.", "Clone your git repo", "rhc app git-clone #{rest_app.name}") output_issues(rest_app) return 0 end if options.git begin run_git_clone(rest_app) rescue RHC::GitException => e warn "#{e}" unless RHC::Helpers.windows? and windows_nslookup_bug?(rest_app) add_issue("We were unable to clone your application's git repo - #{e}", "Clone your git repo", "rhc app git-clone #{rest_app.name}") end end end end display_app(rest_app, rest_app.cartridges, rest_app.scalable_carts.first) if issues? output_issues(rest_app) else results { rest_app.messages.each { |msg| say msg } jenkins_rest_app.messages.each { |msg| say msg } if enable_jenkins? and jenkins_rest_app } end 0 end
# File lib/rhc/commands/app.rb, line 161 def delete(app) rest_domain = rest_client.find_domain(options.namespace) rest_app = rest_domain.find_application(app) do_delete = true do_delete = agree "Are you sure you wish to delete the '#{rest_app.name}' application? (yes/no)" unless options.confirm if do_delete paragraph { say "Deleting application '#{rest_app.name}'" } rest_app.destroy results { say "Application '#{rest_app.name}' successfully deleted" } end 0 end
# File lib/rhc/commands/app.rb, line 202 def force_stop(app) app_action app, :stop, true results { say "#{app} force stopped" } 0 end
TODO: Implement default values for arguments once ffranz has added context arguments argument :directory, "The name of a new directory to clone into", [], :default => nil
# File lib/rhc/commands/app.rb, line 145 def git_clone(app) rest_domain = rest_client.find_domain(options.namespace) rest_app = rest_domain.find_application(app) run_git_clone(rest_app) 0 end
# File lib/rhc/commands/app.rb, line 224 def reload(app) app_action app, :reload results { say "#{app} config reloaded" } 0 end
# File lib/rhc/commands/app.rb, line 213 def restart(app) app_action app, :restart results { say "#{app} restarted" } 0 end
# File lib/rhc/commands/app.rb, line 247 def show(app) rest_domain = rest_client.find_domain(options.namespace) rest_app = rest_domain.find_application(app) unless options.state display_app(rest_app,rest_app.cartridges,rest_app.scalable_carts.first) else results do rest_app.gear_groups.each do |gg| say "Geargroup #{gg.cartridges.collect { |c| c['name'] }.join('+')} is #{gg.gears.first['state']}" end end end 0 end
# File lib/rhc/commands/app.rb, line 180 def start(app) app_action app, :start results { say "#{app} started" } 0 end
# File lib/rhc/commands/app.rb, line 267 def status(app) # TODO: add a way to deprecate this and alias to show --apache options.state = true show(app) end
# File lib/rhc/commands/app.rb, line 191 def stop(app) app_action app, :stop results { say "#{app} stopped" } 0 end
# File lib/rhc/commands/app.rb, line 235 def tidy(app) app_action app, :tidy results { say "#{app} cleaned up" } 0 end