Class: Bamboo::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/bamboo/server.rb

Defined Under Namespace

Classes: HealthCheckClient, Status

Instance Method Summary collapse

Constructor Details

#initialize(client, configuration) ⇒ Service

Returns a new instance of Service.



34
35
36
37
38
# File 'lib/puppet_x/bamboo/server.rb', line 34

def initialize(client, configuration)
  @client = client
  @retries = configuration[:health_check_retries]
  @timeout = configuration[:health_check_timeout]
end

Instance Method Details

#ensure_runningObject

Ensures the referenced Bamboo instance is up and running.

If the service is down or cannot be reached for some reason, the method will wait up to the configured limit. If the retry limit has been reached, the method will raise an exception.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/puppet_x/bamboo/server.rb', line 45

def ensure_running
  for i in 1..@retries do
    result = @client.check_health
    case result.status
      when :not_running
        Puppet.debug("%s Waiting #{@timeout} seconds before trying again." % result.log_message)
        sleep(@timeout)
      when :running
          Puppet.debug("Bamboo service is running.")
        return
      when :broken
        fail(result.log_message)
      else
    end
  end
  fail("Bamboo service did not start up within #{@timeout * @retries} seconds. You should check the Bamboo log " +
    "files to see if something is wrong or consider increasing the timeout if the service is not starting up in " +
    "time.")
end