Skip to content

Instantly share code, notes, and snippets.

@adamwiggins
Created June 23, 2010 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamwiggins/450731 to your computer and use it in GitHub Desktop.
Save adamwiggins/450731 to your computer and use it in GitHub Desktop.
require 'system_timer'
host = '1.2.3.4'
SystemTimer.timeout(1) do
begin
result = `psql -h #{host} -c 'select 1'`
puts "server is up"
rescue Timeout::Error
puts "server is down"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment