Skip to content

Instantly share code, notes, and snippets.

@p5k6
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save p5k6/ed78e22065fad79cf15d to your computer and use it in GitHub Desktop.

Select an option

Save p5k6/ed78e22065fad79cf15d to your computer and use it in GitHub Desktop.
Timeout::timeout(30) do
socket = TCPSocket.new @hive_metastore_server, @hive_metastore_port
begin
socket.write("hello")
socket.close_write
x = socket.read
#not sure when this would happen....
if x.nil?
@monitored_app_state = :unknown
### raise something eventually
else
conditional_log(:running, "hive metastore appears to be running ok")
@monitored_app_state = :running
end
rescue Errno::ECONNRESET,Errno::ECONNREFUSED => e
conditional_log(:dead, "exception #{e} found. This typically occurs when hive-metastore is not running. ")
conditional_log(:dead, 'try running `sudo service hive-metastore status`')
@monitored_app_state = :dead
ensure
socket.close
end
rescue Timeout::Error
## restart hive-metastore!!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment