lib/pitchfork/configurator.rb in pitchfork-0.13.0 vs lib/pitchfork/configurator.rb in pitchfork-0.14.0
- old
+ new
@@ -50,10 +50,12 @@
: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})"
+ elsif worker.service?
+ "service pid=#{worker.pid rescue 'unknown'} gen=#{worker.generation rescue 'unknown'} reaped (#{status.inspect})"
else
"worker=#{worker.nr rescue 'unknown'} pid=#{worker.pid rescue 'unknown'} gen=#{worker.generation rescue 'unknown'} reaped (#{status.inspect})"
end
if status.success?
server.logger.info(m)
@@ -73,10 +75,12 @@
:early_hints => false,
:refork_condition => nil,
:check_client_connection => false,
:rewindable_input => true,
:client_body_buffer_size => Pitchfork::Const::MAX_BODY,
+ :before_service_worker_ready => nil,
+ :before_service_worker_exit => nil,
}
#:startdoc:
def initialize(defaults = {}) #:nodoc:
self.set = Hash.new(:unset)
@@ -172,9 +176,17 @@
set_hook(:after_worker_exit, block_given? ? block : args[0], 3)
end
def after_request_complete(*args, &block)
set_hook(:after_request_complete, block_given? ? block : args[0], 3)
+ end
+
+ def before_service_worker_ready(&block)
+ set_hook(:before_service_worker_ready, block, 2)
+ end
+
+ def before_service_worker_exit(&block)
+ set_hook(:before_service_worker_exit, block, 2)
end
def timeout(seconds, cleanup: 2)
soft_timeout = set_int(:soft_timeout, seconds, 3)
cleanup_timeout = set_int(:cleanup_timeout, cleanup, 2)