lib/ajp-rails/rails-runner.rb in ajp-rails-0.0.3 vs lib/ajp-rails/rails-runner.rb in ajp-rails-0.0.4

- old
+ new

@@ -154,25 +154,32 @@ if is_daemon = options[OPTION_NAMES_TO_INTERNAL_NAMES['daemon']] options.delete(OPTION_NAMES_TO_INTERNAL_NAMES['daemon']) exit if Process.fork - Process.setsid + raise 'Cannot detach from the terminal' unless Process.setsid exit if Process.fork + ObjectSpace.each_object(IO) do |io| + begin + io.close unless [STDIN, STDOUT, STDERR].include?(io) + rescue IOError + # do nothing + end + end File.umask(0) end raise if defined?(RAILS_ENV) ::RAILS_ENV = options['RAILS_ENV'].dup Dir.chdir options[OPTION_NAMES_TO_INTERNAL_NAMES['directory']] require 'config/environment' if is_daemon - Dir.chdir('/') + #Dir.chdir('/') STDIN.reopen('/dev/null') STDOUT.reopen('/dev/null', 'w') - STDERR.reopen('/dev/null', 'w') + STDERR.reopen(STDOUT) end runner = RailsRunner.new(options) runner.start