Class: DaemonKit::Nanite::Agent
- Inherits:
-
Object
- Object
- 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
10 11 12 |
# File 'lib/daemon_kit/nanite/agent.rb', line 10 def instance @instance ||= new end |
.run(&block) ⇒ Object
16 17 18 |
# File 'lib/daemon_kit/nanite/agent.rb', line 16 def run(&block) instance.run(&block) end |
Instance Method Details
#run(&block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/daemon_kit/nanite/agent.rb', line 28 def run(&block) # Ensure graceful shutdown of the connection to the broker DaemonKit.trap('INT') { ::EM.stop } DaemonKit.trap('TERM') { ::EM.stop } # Start our mapper mapper_thread = Thread.new do EM.run do agent = ::Nanite.start_agent( @config.to_h( true ) ) block.call( agent ) if block end end #block.call if block mapper_thread.join end |