From dee4be831cacbb8745b98b894c5e1ebc87078e2c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 30 Oct 2013 22:16:14 +0000 Subject: allow atfork_* hooks inside app blocks for ease-of-management This should allow users to more-easily enable/disable apps and their dependent atfork_* hooks. --- test/test_server.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/test_server.rb') diff --git a/test/test_server.rb b/test/test_server.rb index e6ddefc..6b9f00f 100644 --- a/test/test_server.rb +++ b/test/test_server.rb @@ -408,6 +408,7 @@ class TestServer < Testcase app(:rack, ru) { listen "#{host}:#{port}" persistent_connections false + atfork_child { warn "INFO hihi from app.atfork_child" } } worker_processes(1) do atfork_child { puts "af #$$ worker is running" } @@ -430,6 +431,8 @@ class TestServer < Testcase lines = out.readlines.map!(&:chomp!) out.close! + assert_match %r{INFO hihi from app\.atfork_child}, File.read(err.path) + assert_equal 3, lines.size assert_equal("af #{pid} parent about to spawn", lines.shift) @@ -451,6 +454,7 @@ class TestServer < Testcase app(:rack, ru) { listen "#{host}:#{port}" persistent_connections false + atfork_child { |nr| warn "INFO hihi.#{nr} from app.atfork_child" } } worker_processes(1) do atfork_child { |nr| puts "af.#{nr} #$$ worker is running" } @@ -473,6 +477,7 @@ class TestServer < Testcase lines = out.readlines.map!(&:chomp!) out.close! + assert_match %r{INFO hihi\.0 from app\.atfork_child}, File.read(err.path) assert_equal 3, lines.size assert_equal("af.0 #{pid} parent about to spawn", lines.shift) -- cgit v1.2.3-24-ge0c7