Class: IsItWorking::RubydoraCheck
- Inherits:
-
Object
- Object
- IsItWorking::RubydoraCheck
- Defined in:
- lib/is_it_working/checks/rubydora_check.rb
Instance Method Summary collapse
- #call(status) ⇒ Object
-
#initialize(options = {}) ⇒ RubydoraCheck
constructor
A new instance of RubydoraCheck.
- #ping ⇒ Object
- #profile ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ RubydoraCheck
Returns a new instance of RubydoraCheck.
3 4 5 6 7 8 9 |
# File 'lib/is_it_working/checks/rubydora_check.rb', line 3 def initialize(={}) @client = [:client] raise ArgumentError.new(":client not specified") unless @client @host = @client.client.url @timeout = [:timeout] || 2 @alias = [:alias] || @host end |
Instance Method Details
#call(status) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/is_it_working/checks/rubydora_check.rb', line 11 def call(status) begin ping status.ok("service active") ["repositoryName", "repositoryBaseURL", "repositoryVersion"].each do |key| status.info("#{key} - #{profile[key]}") end rescue Errno::ECONNREFUSED status.fail("#{@alias} is not accepting connections on port #{@port.inspect}") rescue SocketError => e status.fail("connection to #{@alias} on port #{@port.inspect} failed with '#{e.}'") rescue Timeout::Error status.fail("#{@alias} did not respond on port #{@port.inspect} within #{@timeout} seconds") end end |
#ping ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/is_it_working/checks/rubydora_check.rb', line 35 def ping timeout(@timeout) do s = TCPSocket.new(uri.host, uri.port) s.close end true end |
#profile ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/is_it_working/checks/rubydora_check.rb', line 27 def profile @luke ||= begin ActiveFedora::Base.connection_for_pid(0).profile rescue {} end end |
#uri ⇒ Object
43 44 45 |
# File 'lib/is_it_working/checks/rubydora_check.rb', line 43 def uri URI(@host) end |