Class: QPush::Server::Manager
- Inherits:
-
Object
- Object
- QPush::Server::Manager
- Includes:
- ObjectValidator::Validate
- Defined in:
- lib/qpush/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
-
#configs ⇒ Object
Returns the value of attribute configs.
-
#forks ⇒ Object
readonly
Returns the value of attribute forks.
Instance Method Summary collapse
-
#initialize(configs) ⇒ 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(configs) ⇒ Manager
Returns a new instance of Manager.
12 13 14 15 16 17 |
# File 'lib/qpush/server/manager.rb', line 12 def initialize(configs) @configs = configs @master = Process.pid @forks = [] at_exit { shutdown } end |
Instance Attribute Details
#configs ⇒ Object
Returns the value of attribute configs.
9 10 11 |
# File 'lib/qpush/server/manager.rb', line 9 def configs @configs end |
#forks ⇒ Object (readonly)
Returns the value of attribute forks.
10 11 12 |
# File 'lib/qpush/server/manager.rb', line 10 def forks @forks end |
Instance Method Details
#shutdown ⇒ Object
Shutsdown our Worker processes.
33 34 35 36 37 38 39 |
# File 'lib/qpush/server/manager.rb', line 33 def shutdown unless @forks.empty? @forks.each { |w| Process.kill('QUIT', w[:pid].to_i) } end Process.waitall Process.kill('SIGTERM', @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.
23 24 25 26 27 28 29 |
# File 'lib/qpush/server/manager.rb', line 23 def start validate! flush_spaces create_workers Process.wait end |