Class: EY::Model::Instance
Constant Summary collapse
- EYDEPLOY_VERSION =
ENV["EY_DEPLOY_VERSION"] || "1.1.0"
- EXIT_STATUS =
Hash.new { |h,k| raise EY::Error, "ey-deploy version checker exited with unknown status code #{k}" }
Instance Method Summary collapse
- #deploy(app, ref, migration_command = nil, extra_configuration = nil, verbose = false) ⇒ Object
- #ensure_eydeploy_present ⇒ Object
- #ey_deploy_check ⇒ Object
- #has_app_code? ⇒ Boolean
- #install_ey_deploy ⇒ Object
- #put_up_maintenance_page(app, verbose = false) ⇒ Object
- #rollback(app, extra_configuration = nil, verbose = false) ⇒ Object
- #take_down_maintenance_page(app, verbose = false) ⇒ Object
Instance Method Details
#deploy(app, ref, migration_command = nil, extra_configuration = nil, verbose = false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/engineyard/model/instance.rb', line 17 def deploy(app, ref, migration_command=nil, extra_configuration=nil, verbose=false) deploy_args = [ '--app', app.name, '--repo', app.repository_uri, '--stack', environment.stack_name, '--branch', ref, ] if extra_configuration deploy_args << '--config' << extra_configuration.to_json end if migration_command deploy_args << "--migrate" << migration_command end invoke_ey_deploy(deploy_args, verbose) end |
#ensure_eydeploy_present ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/engineyard/model/instance.rb', line 63 def ensure_eydeploy_present case eydeploy_status = ey_deploy_check when :ssh_failed raise EnvironmentError, "SSH connection to #{hostname} failed" when :eydeploy_missing yield :installing if block_given? install_ey_deploy when :ok # no action needed else raise EY::Error, "Internal error: Unexpected status from Instance#ey_deploy_check; got #{eydeploy_status.inspect}" end end |
#ey_deploy_check ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/engineyard/model/instance.rb', line 77 def ey_deploy_check escaped_eydeploy_version = EYDEPLOY_VERSION.gsub(/\./, '\.') if ENV["NO_SSH"] :ok else ssh "#{gem_path} list ey-deploy | grep \"ey-deploy \" | egrep -q '#{escaped_eydeploy_version}[,)]'", false EXIT_STATUS[$?.exitstatus] end end |
#has_app_code? ⇒ Boolean
59 60 61 |
# File 'lib/engineyard/model/instance.rb', line 59 def has_app_code? !["db_master", "db_slave"].include?(role.to_s) end |
#install_ey_deploy ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/engineyard/model/instance.rb', line 88 def install_ey_deploy ssh(Escape.shell_command([ 'sudo', 'sh', '-c', # rubygems looks at *.gem in its current directory for # installation candidates, so we have to make sure it # runs from a directory with no gem files in it. # # rubygems help suggests that --remote will disable this # behavior, but it doesn't. "cd `mktemp -d` && #{gem_path} install ey-deploy --no-rdoc --no-ri -v #{EYDEPLOY_VERSION}"])) end |
#put_up_maintenance_page(app, verbose = false) ⇒ Object
50 51 52 |
# File 'lib/engineyard/model/instance.rb', line 50 def put_up_maintenance_page(app, verbose=false) invoke_ey_deploy(['enable_maintenance_page', '--app', app.name], verbose) end |
#rollback(app, extra_configuration = nil, verbose = false) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/engineyard/model/instance.rb', line 36 def rollback(app, extra_configuration=nil, verbose=false) deploy_args = ['rollback', '--app', app.name, '--stack', environment.stack_name, ] if extra_configuration deploy_args << '--config' << extra_configuration.to_json end invoke_ey_deploy(deploy_args, verbose) end |
#take_down_maintenance_page(app, verbose = false) ⇒ Object
54 55 56 |
# File 'lib/engineyard/model/instance.rb', line 54 def take_down_maintenance_page(app, verbose=false) invoke_ey_deploy(['disable_maintenance_page', '--app', app.name], verbose) end |