From f34618e64b254f7792b476acf2e7eb426aa551a2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 13 Apr 2009 11:46:14 -0700 Subject: Expose worker to {before,after}_fork hooks Instead of just worker.nr. This is a configuration file/API change and will break existing configurations. This allows worker.tempfile to be exposed to the hooks so ownership changes can still happen on it. On the other hand, I don't know of many people actually using this feature (or Unicorn). --- test/exec/test_exec.rb | 6 +++--- test/unit/test_signals.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/exec/test_exec.rb b/test/exec/test_exec.rb index 67a189c..596ab88 100644 --- a/test/exec/test_exec.rb +++ b/test/exec/test_exec.rb @@ -39,8 +39,8 @@ end worker_processes 4 timeout 30 logger Logger.new('#{COMMON_TMP.path}') -before_fork do |server, worker_nr| - server.logger.info "before_fork: worker=\#{worker_nr}" +before_fork do |server, worker| + server.logger.info "before_fork: worker=\#{worker.nr}" end EOS @@ -286,7 +286,7 @@ end File.unlink(tmp.path) ucfg = Tempfile.new('unicorn_test_config') ucfg.syswrite("listen '#@addr:#@port'\n") - ucfg.syswrite("before_fork { |s,nr|\n") + ucfg.syswrite("before_fork { |s,w|\n") ucfg.syswrite(" s.listen('#{tmp.path}', :backlog => 5, :sndbuf => 8192)\n") ucfg.syswrite(" s.listen('#@addr:#{port2}', :rcvbuf => 8192)\n") ucfg.syswrite("\n}\n") diff --git a/test/unit/test_signals.rb b/test/unit/test_signals.rb index 45de263..bedce01 100644 --- a/test/unit/test_signals.rb +++ b/test/unit/test_signals.rb @@ -30,7 +30,7 @@ class SignalsTest < Test::Unit::TestCase tmp.chmod(0) @server_opts = { :listeners => [ "127.0.0.1:#@port", @tmp.path ], - :after_fork => lambda { |server,worker_nr| + :after_fork => lambda { |server,worker| trap(:HUP) { tmp.chmod(n += 1) } }, } -- cgit v1.2.3-24-ge0c7