docs/CONFIGURATION.md in pitchfork-0.10.0 vs docs/CONFIGURATION.md in pitchfork-0.11.0

- old
+ new

@@ -239,14 +239,14 @@ for more details on nginx upstream configuration. ### `spawn_timeout` ```ruby -timeout 5 +spawn_timeout 5 ``` -Sets the timeout for a newly spawned worker to be ready after being spawned. +Sets the timeout for a newly spawned worker or mold to be ready after being spawned. This timeout is a safeguard against various low-level fork safety bugs that could cause a process to dead-lock. The default of `10` seconds is quite generous and likely doesn't need to be adjusted. @@ -282,10 +282,20 @@ after_monitor_ready do |server| server.logger.info("Monitor pid=#{Process.pid} ready") end ``` +### `before_fork` + +Called by the mold before forking a new workers, and by workers before they spawn a new mold. + +```ruby +before_fork do |server| + server.logger.info("About to fork, closing connections!") +end +``` + ### `after_mold_fork` ```ruby after_mold_fork do |server, mold| Database.disconnect! @@ -304,9 +314,14 @@ That is the case for instance of many SQL databases protocols. This is also the callback in which memory optimizations, such as heap compaction should be done. + +This callback is also a good place to check for potential corruption +issues caused by forking. If you detect something wrong, you can +call `Process.exit`, and this mold won't be used, another one will be +spawned later. e.g. you can check `Socket.getaddrinfo` still works, etc. ### `after_worker_fork` ```ruby after_worker_fork do |server, worker|