Module: Nucleus::Adapters::V1::Heroku::Lifecycle

Included in:
Nucleus::Adapters::V1::Heroku
Defined in:
lib/nucleus/adapters/v1/heroku/lifecycle.rb

Instance Method Summary collapse

Instance Method Details

#restart(application_id) ⇒ Object

See Also:



42
43
44
45
46
# File 'lib/nucleus/adapters/v1/heroku/lifecycle.rb', line 42

def restart(application_id)
  log.debug "Restart @ #{@endpoint_url}"
  stop(application_id)
  start(application_id)
end

#start(application_id) ⇒ Object

See Also:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nucleus/adapters/v1/heroku/lifecycle.rb', line 11

def start(application_id)
  log.debug "Start @ #{@endpoint_url}"

  app = application(application_id)
  if app[:state] == Enums::ApplicationStates::DEPLOYED
    # add web dyno if there currently are no dynos (state == deployed)
    scale_web(application_id, 1)
  elsif app[:state] == Enums::ApplicationStates::CREATED
    # fail if there is no deployment
    fail Errors::SemanticAdapterRequestError, 'Application must be deployed before it can be started'
  end

  scale_worker(application_id, 1)
  update_application(application_id, maintenance: false)
end

#stop(application_id) ⇒ Object

See Also:



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/nucleus/adapters/v1/heroku/lifecycle.rb', line 28

def stop(application_id)
  log.debug "Stop @ #{@endpoint_url}"

  # fail if there is no deployment
  app = application(application_id)
  if app[:state] == Enums::ApplicationStates::CREATED
    fail Errors::SemanticAdapterRequestError, 'Application must be deployed before it can be stopped'
  end

  scale_worker(application_id, 0)
  update_application(application_id, maintenance: true)
end