Module: FileDaemon::ClassMethods
- Defined in:
- lib/file_daemon.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#after_fork ⇒ Object
Public: Reopen all file descriptors that have been stored through the before_fork hook.
-
#before_fork ⇒ Object
Public: Store the list of currently open file descriptors so that they may be reopened when a new process is spawned.
Instance Method Details
#after_fork ⇒ Object
Public: Reopen all file descriptors that have been stored through the before_fork hook.
Returns nothing.
30 31 32 33 34 35 36 37 38 |
# File 'lib/file_daemon.rb', line 30 def after_fork @files_to_reopen.each do |file| begin file.reopen file.path, "a+" file.sync = true rescue ::IOError # rubocop:disable HandleExceptions end end end |
#before_fork ⇒ Object
Public: Store the list of currently open file descriptors so that they may be reopened when a new process is spawned.
Returns nothing.
22 23 24 |
# File 'lib/file_daemon.rb', line 22 def before_fork @files_to_reopen ||= ObjectSpace.each_object(File).reject(&:closed?) end |