Skip to content

Instantly share code, notes, and snippets.

Created December 20, 2012 09:22
Show Gist options
  • Save anonymous/4344091 to your computer and use it in GitHub Desktop.
Save anonymous/4344091 to your computer and use it in GitHub Desktop.
script to wait until the resource is ready state.
// requires classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.6'
/**
* Wait until the resource is ready state.
*/
def waitUntilResourceIsReady(String resource) {
def http = new groovyx.net.http.HTTPBuilder(resource)
def check = {
try {
http.get(contentType: groovyx.net.http.ContentType.TEXT)
true
} catch(IOException e) {
logger.warn "Waiting for ${resource}: ${e.localizedMessage}"
false
}
}
Thread.sleep(1000L)
while (!check()) {
Thread.sleep(1000L)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment