Class: DaemonKit::Nanite::Agent
- Defined in:
- lib/daemon_kit/nanite/agent.rb
Overview
Pull support into a daemon for being a nanite agent.
Constant Summary collapse
- @@instance =
nil
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Agent
constructor
A new instance of Agent.
- #run(&block) ⇒ Object
Constructor Details
Class Method Details
.instance ⇒ Object
31 32 33 |
# File 'lib/daemon_kit/nanite/agent.rb', line 31 def instance @instance ||= new end |
.run(&block) ⇒ Object
37 38 39 |
# File 'lib/daemon_kit/nanite/agent.rb', line 37 def run(&block) instance.run(&block) end |
Instance Method Details
#run(&block) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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 |