Method: Merb::BootLoader::LoadClasses.reap_workers
- Defined in:
- lib/merb-core/bootloader.rb
.reap_workers(status = 0, sig = reap_workers_signal) ⇒ Object
Reap any workers of the spawner process and exit with an appropriate status code.
Note that exiting the spawner process with a status code of 128 when a master process exists will cause the spawner process to be recreated, and the app code reloaded.
Parameters
- status<Integer>
-
The status code to exit with. Defaults to 0.
- sig<String>
-
The signal to send to workers
Returns
(Does not return.)
:api: private
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
# File 'lib/merb-core/bootloader.rb', line 826 def reap_workers(status = 0, sig = reap_workers_signal) Merb.logger.info "Executed all before worker shutdown callbacks..." Merb::BootLoader.before_worker_shutdown_callbacks.each do |cb| begin cb.call rescue Exception => e Merb.logger.fatal "before worker shutdown callback crashed: #{e.}" end end Merb.exiting = true unless status == 128 begin if @writer @writer.puts(status.to_s) @writer.close end rescue SystemCallError end threads = [] ($WORKERS || []).each do |p| threads << Thread.new do begin Process.kill(sig, p) Process.wait2(p) rescue SystemCallError end end end threads.each {|t| t.join } exit(status) end |