Class: ActiveHook::Server::Manager
- Inherits:
-
Object
- Object
- ActiveHook::Server::Manager
- Defined in:
- lib/activehook/server/manager.rb
Overview
The Manager controls our Worker processes. We use it to instruct each of them to start and shutdown.
Instance Attribute Summary collapse
-
#forks ⇒ Object
readonly
Returns the value of attribute forks.
-
#options ⇒ Object
Returns the value of attribute options.
-
#workers ⇒ Object
Returns the value of attribute workers.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Manager
constructor
A new instance of Manager.
-
#shutdown ⇒ Object
Shutsdown our Worker processes.
-
#start ⇒ Object
Instantiates new Worker objects, setting them with our options.
Constructor Details
#initialize(options = {}) ⇒ Manager
Returns a new instance of Manager.
10 11 12 13 14 |
# File 'lib/activehook/server/manager.rb', line 10 def initialize( = {}) .each { |key, value| send("#{key}=", value) } @master = Process.pid at_exit { shutdown } end |
Instance Attribute Details
#forks ⇒ Object (readonly)
Returns the value of attribute forks.
8 9 10 |
# File 'lib/activehook/server/manager.rb', line 8 def forks @forks end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/activehook/server/manager.rb', line 7 def @options end |
#workers ⇒ Object
Returns the value of attribute workers.
7 8 9 |
# File 'lib/activehook/server/manager.rb', line 7 def workers @workers end |
Instance Method Details
#shutdown ⇒ Object
Shutsdown our Worker processes.
29 30 31 32 |
# File 'lib/activehook/server/manager.rb', line 29 def shutdown @forks.each { |w| Process.kill('SIGINT', w[:pid].to_i) } Process.kill('SIGINT', @master) end |
#start ⇒ Object
Instantiates new Worker objects, setting them with our options. We follow up by booting each of our Workers. Our Manager is then put to sleep so that our Workers can do their thing.
20 21 22 23 24 25 |
# File 'lib/activehook/server/manager.rb', line 20 def start validate! create_workers Process.wait end |