class Nucleon::Plugin::Agent
Public Class Methods
describe_base(group = nil, action = 'unknown', weight = -1000, description = nil, help = nil, provider_override = nil)
click to toggle source
Calls superclass method
# File lib/core/plugin/agent.rb 13 def self.describe_base(group = nil, action = 'unknown', weight = -1000, description = nil, help = nil, provider_override = nil) 14 group = array(group).collect! {|item| item.to_sym } 15 group = [ :agent ] | group 16 super(group.uniq, action, weight, description, help, provider_override) 17 end
Public Instance Methods
agent_config()
click to toggle source
# File lib/core/plugin/agent.rb 49 def agent_config 50 register_bool :log, true, 'corl.core.action.agent.options.log' 51 register_bool :truncate_log, true, 'corl.core.action.agent.options.truncate_log' 52 53 register_str :log_file, "/var/log/corl/#{plugin_provider}.log", 'corl.core.action.agent.options.log_file' 54 end
arguments()
click to toggle source
# File lib/core/plugin/agent.rb 31 def arguments 32 # Don't use or the default log file naming will screw up due to having to 33 # move daemonization to the corl loader. 34 # 35 # See: lib/corl.rb 36 # 37 [] 38 end
configure() { || ... }
click to toggle source
Calls superclass method
# File lib/core/plugin/agent.rb 22 def configure 23 super do 24 yield if block_given? 25 agent_config 26 end 27 end
execute(use_network = true, &block)
click to toggle source
Calls superclass method
# File lib/core/plugin/agent.rb 59 def execute(use_network = true, &block) 60 super do |node| 61 ensure_network do 62 trap(:INT) do 63 safe_exit 64 end 65 66 add_agent(node) 67 block.call(node) 68 remove_agent(node) if myself.status == code.success 69 end 70 end 71 end
pid()
click to toggle source
# File lib/core/plugin/agent.rb 43 def pid 44 settings[:pid] 45 end
Protected Instance Methods
add_agent(node)
click to toggle source
# File lib/core/plugin/agent.rb 76 def add_agent(node) 77 args = [] 78 79 ARGV.each do |arg| 80 args << ( arg =~ /^\-/ ? arg : "'#{arg}'" ) 81 end 82 83 agent_config = Config.new({ 84 :pid => Process.pid, 85 :args => args.join(' ') 86 }).import(Util::Data.clean(settings.export)) 87 88 agent_config = Util::Data.rm_keys(agent_config.export, [ :node_provider, :nodes, :color, :version ]) 89 node.add_agent(plugin_provider, agent_config) 90 end
remove_agent(node)
click to toggle source
# File lib/core/plugin/agent.rb 95 def remove_agent(node) 96 node.remove_agent(plugin_provider) 97 end
safe_exit()
click to toggle source
# File lib/core/plugin/agent.rb 102 def safe_exit 103 finalize_execution 104 exit status 105 end