Module: PuppetAgentMgr::V3::Unix

Extended by:
Unix
Included in:
Manager, Unix
Defined in:
lib/puppet_agent_mgr/v3/unix.rb

Instance Method Summary collapse

Instance Method Details

#applying?Boolean

is the agent currently applying a catalog

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/puppet_agent_mgr/v3/unix.rb', line 14

def applying?
  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?

Returns:

  • (Boolean)


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

Returns:

  • (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_daemonObject



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