Method: Bard::CLI#ping

Defined in:
lib/bard.rb

#ping(server = :production) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/bard.rb', line 170

def ping server=:production
  server = @config.servers[server.to_sym]
  return false if server.ping == false

  url = server.default_ping
  if server.ping =~ %r{^/}
    url += server.ping
  elsif server.ping.to_s.length > 0
    url = server.ping
  end

  command = "curl -sfL #{url} 2>&1 1>/dev/null"
  unless system command
    puts "#{server.key.to_s.capitalize} is down!"
    exit 1
  end
end