Class: Takeoff::Stage::Heroku::EnableMaintenanceMode

Inherits:
Base
  • Object
show all
Defined in:
lib/takeoff/stage/heroku/enable_maintenance_mode.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Helpers

#branches_up_to_date?, #diff, #execute, #file_has_changed_locally?, #files_have_changed?, #latest_commit, #log

Constructor Details

This class inherits a constructor from Takeoff::Stage::Base

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/takeoff/stage/heroku/enable_maintenance_mode.rb', line 7

def call(env)
  unless env[:dangerous]
    log "Skipping maintenance mode because nothing dangerous is going on"
    
    return @app.call(env) 
  end

  log     "Enabling maintenance mode"
  execute "heroku maintenance:on --remote #{env[:server_remote]}"

  begin
    @app.call(env)
  ensure
    log     "Disabling maintenance mode"
    execute "heroku maintenance:off --remote #{env[:server_remote]}"
  end
end