Permalink
Browse files

create log and pid directories recursively if needed

  • Loading branch information...
rekado committed Oct 20, 2014
1 parent 5934209 commit 91b789ec704b315e81ecddf5559f128c31e233a2
Showing with 9 additions and 1 deletion.
  1. +5 −1 lib/libertree/job-processor.rb
  2. +4 −0 lib/libertree/server.rb
@@ -17,7 +17,7 @@ def initialize(config_filename)
if @conf && @conf['pid_dir']
if ! Dir.exists?(@conf['pid_dir'])
Dir.mkdir @conf['pid_dir']
FileUtils.mkdir_p @conf['pid_dir']
end
pid_filepath = ENV['LIBERTREE_PID_FILEPATH'] || File.join(@conf['pid_dir'], 'job-processor.pid')
@pid = Process.pid
@@ -27,6 +27,10 @@ def initialize(config_filename)
end
if @conf && @conf['log_path']
log_dir = File.dirname(@conf['log_path'])
if ! Dir.exists?(log_dir)
FileUtils.mkdir_p log_dir
end
@log = File.open( @conf['log_path'], 'a+' )
@log.sync = true
else
View
@@ -97,6 +97,10 @@ def self.run(config_filename)
end
if @conf['log_path']
log_dir = File.dirname(@conf['log_path'])
if ! Dir.exists?(log_dir)
FileUtils.mkdir_p log_dir
end
@log_handle = File.open( @conf['log_path'], 'a+' )
@log_handle.sync = true
puts "Logging to #{File.absolute_path(@log_handle.path)}"

0 comments on commit 91b789e

Please sign in to comment.