lib/rack/server.rb in rack-1.3.10 vs lib/rack/server.rb in rack-1.4.0

- old
+ new

@@ -24,11 +24,11 @@ options[:warn] = true } opts.on("-I", "--include PATH", "specify $LOAD_PATH (may be used more than once)") { |path| - (options[:include] ||= []).concat(path.split(":")) + options[:include] = path.split(":") } opts.on("-r", "--require LIBRARY", "require the library, before executing your script") { |library| options[:require] = library @@ -224,11 +224,11 @@ def middleware self.class.middleware end - def start + def start &blk if options[:warn] $-w = true end if includes = options[:include] @@ -245,29 +245,26 @@ p options[:server] pp wrapped_app pp app end - check_pid! if options[:pid] - # Touch the wrapped app, so that the config.ru is loaded before # daemonization (i.e. before chdir, etc). wrapped_app daemonize_app if options[:daemonize] - write_pid if options[:pid] trap(:INT) do if server.respond_to?(:shutdown) server.shutdown else exit end end - server.run wrapped_app, options + server.run wrapped_app, options, &blk end def server @_server ||= Rack::Handler.get(options[:server]) || Rack::Handler.default(options) end @@ -275,11 +272,11 @@ private def parse_options(args) options = default_options # Don't evaluate CGI ISINDEX parameters. - # http://www.meb.uni-bonn.de/docs/cgi/cl.html + # http://hoohoo.ncsa.uiuc.edu/cgi/cl.html args.clear if ENV.include?("REQUEST_METHOD") options.merge! opt_parser.parse!(args) options[:config] = ::File.expand_path(options[:config]) ENV["RACK_ENV"] = options[:environment] @@ -320,30 +317,7 @@ def write_pid ::File.open(options[:pid], 'w'){ |f| f.write("#{Process.pid}") } at_exit { ::File.delete(options[:pid]) if ::File.exist?(options[:pid]) } end - - def check_pid! - case pidfile_process_status - when :running, :not_owned - $stderr.puts "A server is already running. Check #{options[:pid]}." - exit(1) - when :dead - ::File.delete(options[:pid]) - end - end - - def pidfile_process_status - return :exited unless ::File.exist?(options[:pid]) - - pid = ::File.read(options[:pid]).to_i - Process.kill(0, pid) - :running - rescue Errno::ESRCH - :dead - rescue Errno::EPERM - :not_owned - end - end end