mirror of
https://github.com/meineerde/rackstash.git
synced 2026-02-01 01:37:12 +00:00
Open output files with File::SHARE_DELETE to allow logrotates on Windows
This commit is contained in:
parent
13df9ae70b
commit
0f8bdd0be0
@ -228,11 +228,12 @@ module Rackstash
|
||||
dirname = ::File.dirname(path)
|
||||
FileUtils.mkdir_p(dirname) unless ::File.exist?(dirname)
|
||||
|
||||
file = ::File.new(
|
||||
path,
|
||||
::File::WRONLY | ::File::APPEND | ::File::CREAT
|
||||
)
|
||||
file.binmode
|
||||
mode = ::File::WRONLY | ::File::APPEND | ::File::CREAT
|
||||
# Allow external processes to delete the log file on Windows.
|
||||
# This is available since Ruby 2.3.0.
|
||||
mode |= ::File::SHARE_DELETE if defined?(::File::SHARE_DELETE)
|
||||
|
||||
file = ::File.new(path, mode: mode, binmode: true)
|
||||
file.sync = true
|
||||
|
||||
@path = path
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user