Skip to content

Commit

Permalink
Better: Use realpath for logdevice. (#17)
Browse files Browse the repository at this point in the history
* Better: Use realpath for logdevice.

* Keep working with IO

* Add doc + cleaning
  • Loading branch information
ylecuyer authored and elhu committed May 28, 2019
1 parent b189ceb commit 3da2ade
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/peastash/outputs/io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ def self.default_io
end

def initialize(file, *args)
if file.is_a?(String)
# Rewrite symlink path to realpath for instance
# /home/app/releases/20190528155050/log/logstash.log -> /home/app/shared/log/logstash.log
# if the symlinked folder gets deleted on further releases, the log rotation will fail with
# a long wait ending with : log rotation inter-process lock failed.
# realpath is called without the filename because it expects the full path to exists
dir = File.realpath(File.dirname(file))
name = File.basename(file)
file = "#{dir}/#{name}"
end
@device = ::Peastash::LogDevice.new(file, *args)
end

Expand Down

0 comments on commit 3da2ade

Please sign in to comment.