Module: PuppetAgentMgr::V3::Unix
Instance Method Summary collapse
-
#applying? ⇒ Boolean
is the agent currently applying a catalog.
-
#daemon_present? ⇒ Boolean
is the agent daemon currently in the unix process list?.
- #has_process_for_pid?(pid) ⇒ Boolean
- #signal_running_daemon ⇒ Object
Instance Method Details
#applying? ⇒ Boolean
is the agent currently applying a catalog
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/puppet_agent_mgr/v3/unix.rb', line 14 def return false if disabled? if File::Stat.new(Puppet[:agent_catalog_run_lockfile]).size > 0 return has_process_for_pid(File.read(Puppet[:agent_catalog_run_lockfile])) end return false rescue return false end |
#daemon_present? ⇒ Boolean
is the agent daemon currently in the unix process list?
5 6 7 8 9 10 11 |
# File 'lib/puppet_agent_mgr/v3/unix.rb', line 5 def daemon_present? if File.exist?(Puppet[:pidfile]) return has_process_for_pid?(File.read(Puppet[:pidfile])) end return false end |
#has_process_for_pid?(pid) ⇒ Boolean
40 41 42 |
# File 'lib/puppet_agent_mgr/v3/unix.rb', line 40 def has_process_for_pid?(pid) !!Process.kill(0, Integer(pid)) rescue false end |
#signal_running_daemon ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/puppet_agent_mgr/v3/unix.rb', line 26 def signal_running_daemon pid = File.read(Puppet[:pidfile]) if has_process_for_pid?(pid) begin Process.kill("USR1", Integer(pid)) rescue Exception => e raise "Failed to signal the puppet agent at pid %s: %s" % [pid, e.to_s] end else run_in_background end end |