Skip to content

Instantly share code, notes, and snippets.

@gondoi
Created January 4, 2011 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gondoi/765577 to your computer and use it in GitHub Desktop.
Save gondoi/765577 to your computer and use it in GitHub Desktop.
attempting to add gem
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
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