Created
January 4, 2011 22:32
-
-
Save gondoi/765577 to your computer and use it in GitHub Desktop.
attempting to add gem
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
begin | |
require 'sys/proctable' | |
rescue LoadError | |
Chef::Log.warn("Missing gem 'sys-proctable'") | |
end | |
require 'timeout' | |
module Rackspace | |
def self.getProcPid(name) | |
Sys::ProcTable.ps do |p| | |
if /#{name}/ =~ p.cmdline | |
return p.pid | |
end | |
end | |
end | |
def self.wait_on_proc(name, timeout_sec = 60) | |
begin | |
Timeout::timeout(params[:timeout_sec]) do | |
while getProcPid(name) | |
sleep(5) | |
end | |
end | |
rescue | |
Chef::Log.warn("Process #{name} is taking too long, move along!") | |
#Chef::Application.fatal!("Process #{params[:name]} is taking too long, I quit!", -8008) | |
end | |
end | |
def self.is_proc(name, timeout_sec = 60) | |
if getProcPid(name) | |
Chef::Log.info("libcloud deployment script running.") | |
Chef::Log.info("Sleeping for up to #{timeout_sec} seconds...") | |
wait_on_proc(name,timeout_sec) | |
end | |
end | |
end |
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
i = gem_package "sys-proctable" do | |
action :nothing | |
end | |
i.run_action(:install) | |
Gem.clear_paths | |
require 'sys/proctable' | |
Rackspace.is_proc("deployment.*sh", 300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment