Method: CFoundry::V2::App#health

Defined in:
lib/cfoundry/v2/app.rb

#healthObject

Determine application health.

If all instances are running, returns “RUNNING”. If only some are started, returns the precentage of them that are healthy.

Otherwise, returns application’s status.



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/cfoundry/v2/app.rb', line 221

def health
  if state == "STARTED"
    healthy_count = running_instances
    expected = total_instances

    if expected > 0
      ratio = healthy_count / expected.to_f
      if ratio == 1.0
        "RUNNING"
      else
        "#{(ratio * 100).to_i}%"
      end
    else
      "N/A"
    end
  else
    state
  end
end