Class: UnicornHorn::Runner
- Inherits:
-
SelfPipeDaemon
- Object
- SelfPipeDaemon
- UnicornHorn::Runner
- Defined in:
- lib/unicorn_horn/runner.rb
Constant Summary
Constants inherited from SelfPipeDaemon
SelfPipeDaemon::SELF_PIPE, SelfPipeDaemon::SIG_QUEUE
Instance Method Summary collapse
-
#initialize(handlers) ⇒ Runner
constructor
A new instance of Runner.
- #start ⇒ Object
Methods inherited from SelfPipeDaemon
#forget, #ploop, #psleep, #pwake, #register
Constructor Details
Instance Method Details
#start ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/unicorn_horn/runner.rb', line 9 def start register :QUIT, :INT, :TERM, :CHLD, :HUP AFTER_FORK << proc{ @workers.clear; forget } @workers.each(&:launch!) ploop do |signal| reap case signal when nil @workers.each(&:kill_if_idle) @workers.each{ |w| w.wpid or w.launch! } psleep 1 when :CHLD; next when :HUP; raze(:QUIT, 5); when :QUIT; raze(:QUIT, 60); break when :TERM, :INT; raze(:TERM, 5); break end end end |