Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment