Module: Guard::Passenger::Pinger
- Defined in:
- lib/guard/passenger/pinger.rb
Class Method Summary collapse
-
.ping(host, port, notification, path = '/') ⇒ Object
try to ping given url (e.g. localhost:3000/) and display a message to inform of the result failure == response status is 5xx otherwise, it’s a success.
Class Method Details
.ping(host, port, notification, path = '/') ⇒ Object
try to ping given url (e.g. localhost:3000/) and display a message to inform of the result failure == response status is 5xx otherwise, it’s a success
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/guard/passenger/pinger.rb', line 11 def ping(host, port, notification, path = '/') path = "/#{path}" unless path.match(/^\//) ping_in_thread = Thread.start { begin response = Net::HTTP.start(host, port) do |http| http.head(path) end if notification if response.is_a? Net::HTTPServerError Notifier.notify("Passenger is not running!", :title => "Passenger", :image => :failed) else Notifier.notify("Passenger is running.", :title => "Passenger", :image => :success) end end rescue # do nothing end } end |