From c3d8b189d380d5fafb30be671a11b05fb845c063 Mon Sep 17 00:00:00 2001 From: Luis Lavena Date: Wed, 28 Apr 2010 02:34:31 -0300 Subject: [PATCH] Improved Windows platform detection Usage of RbConfig::CONFIG['host_os'] instead of RUBY_PLATFORM. This change improves JRuby support for Mongrel in general. --- History.txt | 1 + bin/mongrel_rails | 2 +- lib/mongrel/configurator.rb | 6 +++--- lib/mongrel/rails.rb | 2 +- test/testhelp.rb | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/History.txt b/History.txt index 9669c3b5..abb845e7 100644 --- a/History.txt +++ b/History.txt @@ -5,6 +5,7 @@ Improvements: * Ruby 1.9 early compatbility: Merged commits form Eric Wong and Matt Aimonetti. * Better RubyGems support thanks to added env she-bang to mongrel_rails executable. * Smartly load http11 extension using fat-binary approach. +* Better detection of Windows platform (usage of RbConfig::CONFIG instead of RUBY_PLATFORM) Bugfixes: diff --git a/bin/mongrel_rails b/bin/mongrel_rails index 92e57abc..ea3839b4 100644 --- a/bin/mongrel_rails +++ b/bin/mongrel_rails @@ -138,7 +138,7 @@ module Mongrel config.join if config.needs_restart - if RUBY_PLATFORM !~ /mswin/ + unless RbConfig::CONFIG['host_os'] =~ /mingw|mswin/ cmd = "ruby #{__FILE__} start #{original_args.join(' ')}" config.log "Restarting with arguments: #{cmd}" config.stop(false, true) diff --git a/lib/mongrel/configurator.rb b/lib/mongrel/configurator.rb index b251c7f9..d07de1e9 100644 --- a/lib/mongrel/configurator.rb +++ b/lib/mongrel/configurator.rb @@ -81,7 +81,7 @@ module Mongrel # Writes the PID file if we're not on Windows. def write_pid_file - if RUBY_PLATFORM !~ /mingw|mswin/ + unless RbConfig::CONFIG['host_os'] =~ /mingw|mswin/ log "Writing PID file to #{@pid_file}" open(@pid_file,"w") {|f| f.write(Process.pid) } open(@pid_file,"w") do |f| @@ -185,7 +185,7 @@ module Mongrel def daemonize(options={}) ops = resolve_defaults(options) # save this for later since daemonize will hose it - if RUBY_PLATFORM !~ /mingw|mswin/ + unless RbConfig::CONFIG['host_os'] =~ /mingw|mswin/ require 'daemons/daemonize' logfile = ops[:log_file] @@ -366,7 +366,7 @@ module Mongrel # clean up the pid file always at_exit { remove_pid_file } - if RUBY_PLATFORM !~ /mingw|mswin/ + unless RbConfig::CONFIG['host_os'] =~ /mingw|mswin/ # graceful shutdown trap("TERM") { log "TERM signal received."; stop } trap("USR1") { log "USR1 received, toggling $mongrel_debug_client to #{!$mongrel_debug_client}"; $mongrel_debug_client = !$mongrel_debug_client } diff --git a/lib/mongrel/rails.rb b/lib/mongrel/rails.rb index 39a2c7db..54bb830b 100644 --- a/lib/mongrel/rails.rb +++ b/lib/mongrel/rails.rb @@ -173,7 +173,7 @@ module Mongrel ops = resolve_defaults(options) setup_signals(options) - if RUBY_PLATFORM !~ /mingw|mswin/ + unless RbConfig::CONFIG['host_os'] =~ /mingw|mswin/ # rails reload trap("HUP") { log "HUP signal received."; reload! } diff --git a/test/testhelp.rb b/test/testhelp.rb index f4d1a3c8..90127cce 100644 --- a/test/testhelp.rb +++ b/test/testhelp.rb @@ -67,5 +67,5 @@ end # Platform check helper ;-) def windows? - result = RUBY_PLATFORM =~ /mingw|mswin/ + @windows ||= RbConfig::CONFIG['host_os'] =~ /mingw|mswin/ end