Class: Rookout::ForkManager
- Inherits:
-
Object
- Object
- Rookout::ForkManager
- Includes:
- Singleton
- Defined in:
- lib/rookout/atfork.rb
Instance Method Summary collapse
- #activate! ⇒ Object
- #active? ⇒ Boolean
- #disable! ⇒ Object
- #fork_hook(original_fork) ⇒ Object
-
#initialize ⇒ ForkManager
constructor
A new instance of ForkManager.
- #post_fork_child ⇒ Object
Constructor Details
#initialize ⇒ ForkManager
Returns a new instance of ForkManager.
6 7 8 |
# File 'lib/rookout/atfork.rb', line 6 def initialize @active = false end |
Instance Method Details
#activate! ⇒ Object
10 11 12 |
# File 'lib/rookout/atfork.rb', line 10 def activate! @active = true end |
#active? ⇒ Boolean
18 19 20 |
# File 'lib/rookout/atfork.rb', line 18 def active? @active end |
#disable! ⇒ Object
14 15 16 |
# File 'lib/rookout/atfork.rb', line 14 def disable! @active = false end |
#fork_hook(original_fork) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rookout/atfork.rb', line 22 def fork_hook original_fork if block_given? original_fork.call do post_fork_child if active? yield end else res = original_fork.call post_fork_child if active? && !res res end end |
#post_fork_child ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rookout/atfork.rb', line 35 def post_fork_child require_relative "rookout_singleton" require_relative "interface" RookoutSingleton.instance.post_fork_clean Interface.instance.stop Interface.instance.start post_fork: true # Disable fork handler in child process disable! end |