From 78a0d5f4321033dbf969edc8f2486bbd5b498dcd Mon Sep 17 00:00:00 2001 From: "roberto@debian32" Date: Fri, 11 Nov 2011 09:57:35 +0100 Subject: [PATCH] added postfork in uwsgidsl --- config30.ru | 15 ++++----------- uwsgidsl.rb | 13 +++++++++++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/config30.ru b/config30.ru index 9f72689d..8dd71257 100644 --- a/config30.ru +++ b/config30.ru @@ -3,22 +3,11 @@ require 'uwsgidsl' -module UWSGI - - module_function - def post_fork_hook() - puts "fork() called" - end -end - -puts UWSGI.respond_to?('post_fork_hook') - signal 17,'mule5' do |signum| end puts UWSGI::OPT.inspect - timer 2 do |signum| puts "ciao sono un dsl ruby: #{signum} #{UWSGI::OPT.inspect}" end @@ -39,6 +28,10 @@ cron 58,-1,-1,-1,-1 do |signum| puts "cron ready #{signum}" end +postfork do + puts "fork() called" +end + begin foo_func rescue diff --git a/uwsgidsl.rb b/uwsgidsl.rb index 85fc6891..c5648930 100644 --- a/uwsgidsl.rb +++ b/uwsgidsl.rb @@ -12,6 +12,15 @@ def get_free_signal() end end +$postfork_chain = [] + +module UWSGI + module_function + def post_fork_hook() + $postfork_chain.each {|func| func.call } + end +end + def timer(secs, target='', &block) freesig = get_free_signal UWSGI.register_signal(freesig, target, block) @@ -39,3 +48,7 @@ end def signal(signum, target='', &block) UWSGI.register_signal(signum, target, block) end + +def postfork(&block) + $postfork_chain << block +end