lib/pitchfork/configurator.rb in pitchfork-0.5.0 vs lib/pitchfork/configurator.rb in pitchfork-0.6.0

- old
+ new

@@ -24,22 +24,27 @@ :set_listener => false, :options => { :listeners => [] } } # Default settings for Pitchfork + default_logger = Logger.new($stderr) + default_logger.formatter = Logger::Formatter.new + default_logger.progname = "[Pitchfork]" + DEFAULTS = { :soft_timeout => 20, :cleanup_timeout => 2, :timeout => 22, - :logger => Logger.new($stderr), + :logger => default_logger, :worker_processes => 1, :after_worker_fork => lambda { |server, worker| server.logger.info("worker=#{worker.nr} gen=#{worker.generation} pid=#{$$} spawned") }, :after_mold_fork => lambda { |server, worker| server.logger.info("mold gen=#{worker.generation} pid=#{$$} spawned") }, + :before_worker_exit => nil, :after_worker_exit => lambda { |server, worker, status| m = if worker.nil? "repead unknown process (#{status.inspect})" elsif worker.mold? "mold pid=#{worker.pid rescue 'unknown'} gen=#{worker.generation rescue 'unknown'} reaped (#{status.inspect})" @@ -54,10 +59,11 @@ }, :after_worker_ready => lambda { |server, worker| server.logger.info("worker=#{worker.nr} gen=#{worker.generation} ready") }, :after_worker_timeout => nil, + :after_worker_hard_timeout => nil, :after_request_complete => nil, :early_hints => false, :refork_condition => nil, :check_client_connection => false, :rewindable_input => true, @@ -135,9 +141,17 @@ set_hook(:after_worker_ready, block_given? ? block : args[0]) end def after_worker_timeout(*args, &block) set_hook(:after_worker_timeout, block_given? ? block : args[0], 3) + end + + def after_worker_hard_timeout(*args, &block) + set_hook(:after_worker_hard_timeout, block_given? ? block : args[0], 2) + end + + def before_worker_exit(*args, &block) + set_hook(:before_worker_exit, block_given? ? block : args[0], 2) end def after_worker_exit(*args, &block) set_hook(:after_worker_exit, block_given? ? block : args[0], 3) end