Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes our failing dependency checks #142

Merged
merged 1 commit into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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