-
-
Save schisamo/764267 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'timeout' | |
include Rackspace::Proc | |
define :wait_on_proc, :timeout_sec => 60 do | |
include_recipe "rackspace" | |
begin | |
Timeout::timeout(params[:timeout_sec]) do | |
while getProcPid(params[:name]) | |
sleep(5) | |
end | |
end | |
rescue | |
Chef::Log.warn("Process #{params[:name]} is taking too long, move along!") | |
#Chef::Application.fatal!("Process #{params[:name]} is taking too long, I quit!", -8008) | |
end | |
end | |
define :is_proc, :timeout_sec => 60 do | |
include_recipe "rackspace" | |
if getProcPid(params[:name]) | |
Chef::Log.info("libcloud deployment script running.") | |
Chef::Log.info("Sleeping for up to #{params[:timeout_sec]} seconds...") | |
wait_on_proc params[:name] do | |
timeout_sec params[:timeout_sec] | |
end | |
end | |
end |
This file contains hidden or 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 | |
module Rackspace | |
module Proc | |
def getProcPid(name) | |
Sys::ProcTable.ps{ |p| | |
if /#{name}/ =~ p.cmdline | |
return p.pid | |
end | |
} | |
end | |
end | |
end |
This file contains hidden or 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
# force the gem to be installed during the compile phase | |
# of the chef run | |
r = gem_package "sys-proctable" do | |
action :nothing | |
end | |
r.run_action(:install) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment