diff options
-rw-r--r-- | lib/unicorn.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 6d0eccb..9510e4b 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -101,9 +101,6 @@ module Unicorn raise ArgumentError, "no listeners" if LISTENERS.empty? self.pid = @config[:pid] build_app! if @preload_app - File.open(@stderr_path, "a") { |fp| $stderr.reopen(fp) } if @stderr_path - File.open(@stdout_path, "a") { |fp| $stdout.reopen(fp) } if @stdout_path - $stderr.sync = $stdout.sync = true spawn_missing_workers self end @@ -139,6 +136,9 @@ module Unicorn (set_names - cur_names).each { |addr| listen(addr) } end + def stdout_path=(path); redirect_io($stdout, path); end + def stderr_path=(path); redirect_io($stderr, path); end + # sets the path for the PID file of the master process def pid=(path) if path @@ -598,5 +598,10 @@ module Unicorn START_CTX[:argv]).join(' ') end + def redirect_io(io, path) + File.open(path, 'a') { |fp| io.reopen(fp) } if path + io.sync = true + end + end end |