Created
January 3, 2011 20:47
-
-
Save gondoi/763942 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
[Tue, 04 Jan 2011 20:39:33 +0000] ERROR: Re-raising exception: NameError - uninitialized constant Sys | |
/tmp/chef-solo/cookbooks/rackspace/libraries/proctable.rb:25:in `getProcPid' | |
/tmp/chef-solo/cookbooks/rackspace/definitions/proc.rb:26:in `block in from_file' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/recipe_definition_dsl_core.rb:50:in `instance_eval' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/recipe_definition_dsl_core.rb:50:in `method_missing' | |
/tmp/chef-solo/cookbooks/rackspace/recipes/mckick.rb:16:in `from_file' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/from_file.rb:30:in `instance_eval' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/from_file.rb:30:in `from_file' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/cookbook_version.rb:337:in `load_recipe' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/language_include_recipe.rb:40:in `block in include_recipe' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/language_include_recipe.rb:27:in `each' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/run_context.rb:94:in `block in load' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/run_context.rb:91:in `each' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/run_context.rb:91:in `load' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/run_context.rb:55:in `initialize' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/client.rb:84:in `new' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/client.rb:84:in `run' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/application/solo.rb:191:in `block in run_application' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/application/solo.rb:181:in `loop' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/application/solo.rb:181:in `run_application' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/application.rb:62:in `run' | |
/opt/ruby/lib/ruby/gems/chef-0.9.8/bin/chef-solo:25:in `<top (required)>' | |
/opt/ruby/lib/ruby/bin/chef-solo:19:in `load' | |
/opt/ruby/lib/ruby/bin/chef-solo:19:in `<main>' |
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' | |
define :wait_on_proc, :timeout_sec => 60 do | |
include_recipe "rackspace" | |
begin | |
Timeout::timeout(params[:timeout_sec]) do | |
Gem.clear_paths | |
while Rackspace.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" | |
Gem.clear_paths | |
if Rackspace.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 | |
begin | |
include Sys | |
rescue NameError | |
Chef::Log.warn("Missing name 'Sys'") | |
end | |
module Rackspace | |
def self.getProcPid(name) | |
Gem.clear_paths | |
::Sys::ProcTable.ps do |p| | |
if /#{name}/ =~ p.cmdline | |
return p.pid | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment