about summary refs log tree commit homepage
path: root/lib/unicorn/worker.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2017-02-17 16:12:33 -0800
committerEric Wong <e@80x24.org>2017-02-21 21:27:27 +0000
commit2af91a1fef70d6546ee03760011c170a082db667 (patch)
treec41faa65f4786cc0312e64ebef6759d162a785b0 /lib/unicorn/worker.rb
parent2c6aa5878d052abb77c6d119e1c2e2110118a244 (diff)
downloadunicorn-2af91a1fef70d6546ee03760011c170a082db667.tar.gz
This option is executed in the master process following all
worker process exits.  It is most useful in the case where
the worker process crashes the ruby interpreter, as the worker
process may not be able to send error notifications
appropriately.

For example, let's say you have a specific request that crashes a
worker process, which you expect to be due to a improperly
programmed C extension. By modifying your worker to save request
related data in a temporary file and using this option, you can get
a record of what request is crashing the application, which will
make debugging easier.

Example:

after_worker_exit do |server, worker, status|
  server.logger.info "worker #{status.success? ? 'exit' : 'crash'}: #{status}"

  file = "request.#{status.pid}.txt"
  if File.exist?(file)
    do_something_with(File.read(file)) unless status.success?
    File.delete(file)
  end
end
Diffstat (limited to 'lib/unicorn/worker.rb')
0 files changed, 0 insertions, 0 deletions