From 4905d82fc0f96a79f2d3a5d9eaf93c1112684d7c Mon Sep 17 00:00:00 2001 From: zedshaw Date: Tue, 23 May 2006 03:42:37 +0000 Subject: Bug 4414 fixed, should no longer clobber pid file git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@205 19e92222-5c0b-0410-8929-a290d50e31e9 --- bin/mongrel_rails | 1 + lib/mongrel.rb | 17 +++++++++++------ lib/mongrel/rails.rb | 4 +--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/bin/mongrel_rails b/bin/mongrel_rails index 46c4dad..b6ba92f 100644 --- a/bin/mongrel_rails +++ b/bin/mongrel_rails @@ -143,6 +143,7 @@ class Start < GemPlugin::Plugin "/commands" config.run config.log "Mongrel available at #{settings[:host]}:#{settings[:port]}" config.log "Use CTRL-C to stop." if not @daemon + config.write_pid_file config.join if config.needs_restart diff --git a/lib/mongrel.rb b/lib/mongrel.rb index 187df04..a3e4fec 100644 --- a/lib/mongrel.rb +++ b/lib/mongrel.rb @@ -699,6 +699,8 @@ module Mongrel # A major thing about Configurator is that it actually lets you configure # multiple listeners for any hosts and ports you want. These are kept in a # map config.listeners so you can get to them. + # + # * :pid_file => Where to write the process ID. class Configurator attr_reader :listeners attr_reader :defaults @@ -730,7 +732,14 @@ module Mongrel Process::UID.change_privilege(Etc.getpwnam(user).uid) end end - + + # Writes the PID file but only if we're on windows. + def write_pid_file + if RUBY_PLATFORM !~ /mswin/ + open(@pid_file,"w") {|f| f.write(Process.pid) } + end + end + # generates a class for cloaking the current self and making the DSL nicer def cloaking_class class << self @@ -811,7 +820,6 @@ module Mongrel # # * :cwd => Directory to change to. # * :log_file => Where to write STDOUT and STDERR. - # * :pid_file => Where to write the process ID. # # It is safe to call this on win32 as it will only require the daemons # gem/library if NOT win32. @@ -826,7 +834,6 @@ module Mongrel # change back to the original starting directory Dir.chdir(ops[:cwd]) - open(ops[:pid_file],"w") {|f| f.write(Process.pid) } else log "WARNING: Win32 does not support daemon mode." end @@ -966,7 +973,7 @@ module Mongrel # It only configures if the platform is not win32 and doesn't do # a HUP signal since this is typically framework specific. # - # Requires a :pid_file option to indicate a file to delete. + # Requires a :pid_file option given to Configurator.new to indicate a file to delete. # It sets the MongrelConfig.needs_restart attribute if # the start command should reload. It's up to you to detect this # and do whatever is needed for a "restart". @@ -975,8 +982,6 @@ module Mongrel def setup_signals(options={}) ops = resolve_defaults(options) - @pid_file = ops[:pid_file] - # forced shutdown, even if previously restarted (actually just like TERM but for CTRL-C) trap("INT") { log "INT signal received."; stop(need_restart=false) } diff --git a/lib/mongrel/rails.rb b/lib/mongrel/rails.rb index 6bc3b2d..8ebd76d 100644 --- a/lib/mongrel/rails.rb +++ b/lib/mongrel/rails.rb @@ -21,8 +21,6 @@ require 'cgi' module Mongrel module Rails - - # Implements a handler that can run Rails and serve files out of the # Rails application's public directory. This lets you run your Rails # application with Mongrel during development and testing, then use it @@ -65,7 +63,7 @@ module Mongrel return if response.socket.closed? path_info = request.params[Mongrel::Const::PATH_INFO] - page_cached = request.params[Mongrel::Const::PATH_INFO] + ".html" + page_cached = path_info + ".html" if @files.can_serve(path_info) # File exists as-is so serve it up -- cgit v1.2.3-24-ge0c7