From 2deefc545278f2adf6b1bb7fc6de07b3efb98d61 Mon Sep 17 00:00:00 2001 From: Manabu Ejima Date: Thu, 15 Dec 2016 01:45:10 +0900 Subject: [PATCH] Raise error when `stdout` or `stderr` is not writable --- lib/puma/runner.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/puma/runner.rb b/lib/puma/runner.rb index 72f37798d4..339c272d1e 100644 --- a/lib/puma/runner.rb +++ b/lib/puma/runner.rb @@ -107,12 +107,20 @@ def redirect_io append = @options[:redirect_append] if stdout + unless Dir.exists?(File.dirname(stdout)) + raise "Cannot redirect STDOUT to #{stdout}" + end + STDOUT.reopen stdout, (append ? "a" : "w") STDOUT.sync = true STDOUT.puts "=== puma startup: #{Time.now} ===" end if stderr + unless Dir.exists?(File.dirname(stderr)) + raise "Cannot redirect STDERR to #{stderr}" + end + STDERR.reopen stderr, (append ? "a" : "w") STDERR.sync = true STDERR.puts "=== puma startup: #{Time.now} ==="