mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 19:06:12 +02:00
Fix bug: pid become zero when pid file is empty
This commit is contained in:
parent
7eddae31b7
commit
50b5fbed54
@ -55,6 +55,7 @@ class Fluentd
|
||||
|
||||
def pid
|
||||
return unless File.exists?(pid_file)
|
||||
return if File.zero?(pid_file)
|
||||
File.read(pid_file).to_i rescue nil
|
||||
end
|
||||
|
||||
|
||||
@ -20,10 +20,10 @@ describe 'Fluentd::Agent::LocalCommon' do
|
||||
end
|
||||
|
||||
context 'valid pid file given' do
|
||||
before { File.write pid_file_path, '99999' }
|
||||
before { File.write pid_file_path, '9999' }
|
||||
after { FileUtils.rm pid_file_path }
|
||||
|
||||
its(:pid) { should eq(99999) }
|
||||
its(:pid) { should eq(9999) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user