Guest User

Untitled

a guest
Jan 27th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.14 KB | None | 0 0
  1.         logfile = "/var/log/#{application}/#{application}.log"
  2.         notifier = INotify::Notifier.new
  3.                
  4.         #check if service-is healthy
  5.           begin
  6.             tries ||= 70
  7.             http = HTTPClient.new
  8.             url = "http://localhost:8080/ping"
  9.             response = http.get(url)
  10.           rescue Errno::ECONNREFUSED, HTTPClient::BadResponseError => e
  11.             Log.info("Retry ping no. : #{tries}")
  12.             tries -= 1
  13.             if tries > 0
  14.               sleep 1
  15.               notifier.watch(logfile, :modify) do
  16.                 @line = f.readline
  17.                 Log.info "logline: #{@line}" # this never happens!
  18.                 @output << @line
  19.               end
  20.               retry
  21.             else
  22.               Log.info "Error from log file:"
  23.               Log.info "============= /var/log/#{application}/#{application}.log ============="
  24.               Log.info "#{@output}"
  25.               Log.info "============= /var/log/#{application}/#{application}.log ============="
  26.               f.close
  27.               raise "Error while trying to ping application #{e}"
  28.             end
  29.           end
Advertisement
Add Comment
Please, Sign In to add comment