Skip to content

Instantly share code, notes, and snippets.

@djvs
Last active August 29, 2015 14:26
Show Gist options
  • Save djvs/37cb5dc7047a431c51ad to your computer and use it in GitHub Desktop.
Save djvs/37cb5dc7047a431c51ad to your computer and use it in GitHub Desktop.
Ubuntu neo4j uptime watcher (alpha)
require 'timeout'
def restartneo4j
puts "restarting neo4j"
`sudo service neo4j-service restart"`
end
begin
Timeout::timeout(5){
@output = `curl http://localhost:7474`
}
if [email protected]?("management") # server responds incorrectly
restartneo4j
else # server responds correctly
puts @output.inspect
puts "everything is ok"
end
rescue # server does not respond
restartneo4j
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment