Skip to content

Commit

Permalink
Merge pull request #142 from CDL-Dryad/fix-dependency-checker
Browse files Browse the repository at this point in the history
Fixes our failing dependency checks
  • Loading branch information
ryscher authored May 26, 2020
2 parents 024228a + 12b72dd commit 62cddc6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ GEM
passenger (6.0.4)
rack
rake (>= 0.8.1)
posix-spawn (0.3.13)
posix-spawn (0.3.14)
postrank-uri (1.0.24)
addressable (>= 2.4.0)
nokogiri (>= 1.8.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ def report_outage
end

def extract_last_log_date(log)
contents = File.open(log).to_a
contents = read_end_of_file(log)
last_run_date = Time.parse(contents.last.match(DATE_TIME_MATCHER).to_s) unless contents.empty?
last_run_date
end

def read_end_of_file(log)
f = File.new(log)
f.seek(-512, IO::SEEK_END) # to 512 bytes before end of file
f.read.strip.split("\n") # this reads just end of file, strips whitespace and converts to array of lines
end

end

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class OaiService < DependencyCheckerService

def ping_dependency
super
env = Rails.env.production? ? 'prd' : 'stg'
target = "http://uc3-mrtoai-#{env}.cdlib.org:37001/mrtoai/state"
env = Rails.env.production? ? 'mrtoai.cdlib.org' : 'mrtoai-stg.cdlib.org'
target = "http://#{env}:37001/mrtoai/state"
resp = HTTParty.get(target)
online = resp.code == 200
msg = resp.body unless online
Expand Down

0 comments on commit 62cddc6

Please sign in to comment.