docs/CONFIGURATION.md in pitchfork-0.13.0 vs docs/CONFIGURATION.md in pitchfork-0.14.0

- old
+ new

@@ -297,12 +297,17 @@ ### `after_mold_fork` ```ruby after_mold_fork do |server, mold| Database.disconnect! + + # Ruby < 3.3 3.times { GC.start } # promote surviving objects to oldgen GC.compact + + # Ruby >= 3.3 + Process.warmup end ``` Called in the context of the mold after it has been spawned. @@ -414,9 +419,42 @@ if something_wrong? exit end end ``` + +### `before_service_worker_ready` (experimental) + +Experimental and may change at any point. + +If defined, Pitchfork will spawn one extra worker, called a service worker +which doesn't accept incoming requests, but allows to perform service tasks +such as warming node local caches or emitting metrics. + +Service workers are never promoted to molds, so it is safe to use threads and +other fork unsafe APIs. + +This callback MUST not block. It should start one or multiple background threads +to perform tasks at regular intervals. + +```ruby +before_service_worker_ready do |server, service_worker| + Thread.new do + loop do + MyApp.emit_utilization_metrics + sleep 1 + end + end +end +``` + +### `before_service_worker_exit` (experimental) + +Experimental and may change at any point. + +Optional. + +Called whenever the service worker is exiting. This allow to do a clean shutdown. ## Reforking ### `refork_after`