Last active
December 14, 2015 20:49
-
-
Save annappropriate/5f82426094d87f6a33f9 to your computer and use it in GitHub Desktop.
Prototype of Chef service poking script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# url => link to poke | |
# name => human-readable name | |
# anchor => phrase to look for at page | |
define :poke_service do | |
def is_loaded? | |
Timeout::timeout(3) { | |
open params[:url].read.include? params[:anchor] | |
} | |
rescue WhateverExceptionsThereHappen | |
puts "#{params[:name]} is loading..."; sleep 10 and reload | |
end | |
if is_loaded? | |
puts "#{params[:name]} is now up and running, check it out!" | |
end | |
end | |
end | |
# Use like this: | |
poke_service "Kittens" do | |
url "http://#{node[:kittens][:host]}:#{node[:kittens][:port]}/stuffs/login.html" | |
anchor "alive" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment