stderr_path doesn't work at the moment of being called

Iñaki Baz Castillo ibc at aliax.net
Tue Jan 5 05:26:32 EST 2010


Hi, in unicorn.conf.rb I want to log a welcome message (current datetime 
basically) to the error log, so I do:

  if Process.ppid == 1 || Process.getpgrp != $$
    stderr_path "/tmp/error.log"
    $stderr.puts "#{Time.now} Starting..."

Unfortunatelly the message is displayed in the terminal rather than the file.

However with the following hacks the message is displayed in the file:

a)
  stderr_path "/tmp/error.log"
  $stderr.reopen "/tmp/error.log"
  $stderr.puts "#{Time.now} Starting..."

b)
  stderr_path "/tmp/error.log"
  File.open("/tmp/error.log", 'ab') { |fp| $stderr.reopen(fp) }
  $stderr.puts "#{Time.now} Starting..."
  

The second workaround is exactly what Unicorn does when calling to 
"stderr_path" ("redirect_io" method). So, why doesn't work for me without the 
hacks? do I miss something?

Thanks a lot.

-- 
Iñaki Baz Castillo <ibc at aliax.net>


More information about the mongrel-unicorn mailing list