Skip to content

Instantly share code, notes, and snippets.

@annappropriate
Last active December 14, 2015 20:49
Show Gist options
  • Save annappropriate/5f82426094d87f6a33f9 to your computer and use it in GitHub Desktop.
Save annappropriate/5f82426094d87f6a33f9 to your computer and use it in GitHub Desktop.
Prototype of Chef service poking script
# 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