Created
March 16, 2021 14:02
-
-
Save fnordfish/7265102b156496b767c8dba098fd8f51 to your computer and use it in GitHub Desktop.
trap HUP to reopen logfile in ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$logger = Logger.new("my.log") | |
prev_trap = Signal.trap("HUP") do |*args| | |
$logger.reopen | |
prev_trap.call(*args) if prev_trap.respond_to?(:call) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment