Parent

DaemonKit::Nanite::Agent

Pull support into a daemon for being a nanite agent.

Public Class Methods

instance() click to toggle source
# File lib/daemon_kit/nanite/agent.rb, line 31
def instance
  @instance ||= new
end
new() click to toggle source
# File lib/daemon_kit/nanite/agent.rb, line 43
def initialize
  @config = DaemonKit::Config.load( 'nanite' ).to_h( true )

  config_agent
end
run(&block) click to toggle source
# File lib/daemon_kit/nanite/agent.rb, line 37
def run(&block)
  instance.run(&block)
end

Public Instance Methods

run(&block) click to toggle source
# File lib/daemon_kit/nanite/agent.rb, line 49
def run(&block)
  # Ensure graceful shutdown of the connection to the broker
  DaemonKit.trap('INT') { ::EM.stop }
  DaemonKit.trap('TERM') { ::EM.stop }
  ::Nanite::Log.logger = DaemonKit.logger

  # Start our mapper
  mapper_thread = Thread.new do
    EM.run do
      agent = ::Nanite::Agent.new( @config )
      agent.init_block = block
      agent.run
    end
  end

  mapper_thread.join
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.