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 53 def create(name, cartridges) cartridges = check_cartridges(cartridges, &require_one_web_cart) options.default :dns => true, :git => true 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? raise RHC::Rest::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) rest_app = nil cart_names = cartridges.collect do |c| c.usage_rate? ? "#{c.name} (addtl. costs may apply)" : c.name end.join(', ') paragraph do header "Application Options" table([["Namespace:", options.namespace], ["Cartridges:", cart_names], (["Source Code:", options.from_code] if options.from_code), ["Gear Size:", options.gear_size || "default"], ["Scaling:", options.scaling ? "yes" : "no"], ].compact ).each { |s| say " #{s}" } end messages = [] paragraph do say "Creating application '#{name}' ... " # create the main app rest_app = create_app(name, cartridges.map(&:name), rest_domain, options.gear_size, options.scaling, options.from_code) messages.concat(rest_app.messages) success "done" end build_app_exists = rest_app.building_app if enable_jenkins? unless build_app_exists paragraph do say "Setting up a Jenkins application ... " begin build_app_exists = add_jenkins_app(rest_domain) success "done" messages.concat(build_app_exists.messages) rescue Exception => e warn "not complete" 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 end end paragraph do add_jenkins_client_to(rest_app, messages) end if build_app_exists end if options.dns paragraph do say "Waiting for your DNS name to be available ... " if dns_propagated? rest_app.host success "done" else warn "failure" 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 git-clone #{rest_app.name}") output_issues(rest_app) return 0 end end if options.git paragraph do debug "Checking SSH keys through the wizard" check_sshkeys! unless options.noprompt say "Downloading the application Git repository ..." paragraph do begin git_clone_application(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 git-clone #{rest_app.name}") end end end end end end display_app(rest_app, rest_app.cartridges) if issues? output_issues(rest_app) else results{ messages.each { |msg| success msg } }.blank? and "Application created" end 0 end
# File lib/rhc/commands/app.rb, line 183 def delete(app) rest_app = rest_client.find_application(options.namespace, app) confirm_action "#{color("This is a non-reversible action! Your application code and data will be permanently deleted if you continue!", :yellow)}\n\nAre you sure you want to delete the application '#{app}'?" say "Deleting application '#{rest_app.name}' ... " rest_app.destroy success "deleted" 0 end
# File lib/rhc/commands/app.rb, line 221 def force_stop(app) app_action app, :stop, true results { say "#{app} force stopped" } 0 end
# File lib/rhc/commands/app.rb, line 243 def reload(app) app_action app, :reload results { say "#{app} config reloaded" } 0 end
# File lib/rhc/commands/app.rb, line 232 def restart(app) app_action app, :restart results { say "#{app} restarted" } 0 end
# File lib/rhc/commands/app.rb, line 267 def show(app_name) if options.state gear_groups_for_app(app_name).each do |gg| say "Cartridge #{gg.cartridges.collect { |c| c['name'] }.join(', ')} is #{gear_group_state(gg.gears.map{ |g| g['state'] })}" end elsif options.gears say table(gear_groups_for_app(app_name).map{ |gg| gg.gears.map{ |g| [g['id'], g['state'], gg.cartridges.map{ |c| c['name'] }.join(", ")] } }.flatten(1)) else app = rest_client.find_application(options.namespace, app_name, :include => :cartridges) display_app(app, app.cartridges) end 0 end
# File lib/rhc/commands/app.rb, line 289 def ssh(app_name) raise ArgumentError, "No application specified" unless app_name.present? raise OptionParser::InvalidOption, "No system SSH available. Please use the --ssh option to specify the path to your SSH executable, or install SSH." unless options.ssh or has_ssh? rest_app = rest_client.find_application(options.namespace, app_name) say "Connecting to #{rest_app.ssh_string.to_s} ..." if options.ssh debug "Using user specified SSH: #{options.ssh}" Kernel.send(:system, "#{options.ssh} #{rest_app.ssh_string.to_s}") else debug "Using system ssh" Kernel.send(:system, "ssh #{rest_app.ssh_string.to_s}") end end
# File lib/rhc/commands/app.rb, line 199 def start(app) app_action app, :start results { say "#{app} started" } 0 end
# File lib/rhc/commands/app.rb, line 310 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 210 def stop(app) app_action app, :stop results { say "#{app} stopped" } 0 end
# File lib/rhc/commands/app.rb, line 254 def tidy(app) app_action app, :tidy results { say "#{app} cleaned up" } 0 end