From 9d120bf9b5a2caccddfedae428b8057a3fa66539 Mon Sep 17 00:00:00 2001 From: zedshaw Date: Sun, 5 Mar 2006 07:58:18 +0000 Subject: New plugin loading system that works entirely with rubygems rather than custo-hacking files. git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@80 19e92222-5c0b-0410-8929-a290d50e31e9 --- bin/mongrel_rails | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/mongrel_rails b/bin/mongrel_rails index 2b363bd..059c782 100644 --- a/bin/mongrel_rails +++ b/bin/mongrel_rails @@ -1,5 +1,6 @@ require 'rubygems' require 'mongrel/rails' +require 'yaml' class Start < Mongrel::Plugin "/commands" @@ -18,7 +19,6 @@ class Start < Mongrel::Plugin "/commands" ['-m', '--mime PATH', "A YAML file that lists additional MIME types", :@mime_map, nil], ['-c', '--chdir PATH', "Change to dir before starting (will be expanded)", :@cwd, Dir.pwd], ['-r', '--root PATH', "Set the document root (default 'public')", :@docroot, "public"], - ['-L', '--load PATH', "Loads plugins from the given directory", :@load_from, nil], ] end @@ -34,8 +34,6 @@ class Start < Mongrel::Plugin "/commands" valid_dir? @docroot, "Path to docroot not valid: #@docroot" valid_exists? @mime_map, "MIME mapping file does not exist: #@mime_map" if @mime_map - valid_dir? @load_from, "Plugin directory path does not exist" if @load_from - return @valid end @@ -87,6 +85,8 @@ class Start < Mongrel::Plugin "/commands" server = Mongrel::HttpServer.new(@address, @port, @num_procs.to_i, @timeout.to_i) server.register("/", rails) + + # start mongrel processing thread server.run # signal trapping just applies to posix systems @@ -109,7 +109,10 @@ class Start < Mongrel::Plugin "/commands" @restart = true } end - + + # hook up any rails specific plugins + Mongrel::PluginManager.instance.load(MONGREL_PLUGINS_DIR) + begin STDERR.puts "Server ready." server.acceptor.join @@ -123,7 +126,6 @@ class Start < Mongrel::Plugin "/commands" end def run - Mongrel::PluginManager.instance.load(@load_from) if @load_from daemonize rails = configure_rails start_mongrel(rails) @@ -212,5 +214,13 @@ class Restart < Mongrel::Plugin "/commands" end end +if ARGV[0] == "-L" || ARGV[0] == "--load" + ARGV.shift # drop the -L + MONGREL_PLUGINS_DIR=ARGV.shift +else + MONGREL_PLUGINS_DIR=nil +end + +Mongrel::PluginManager.instance.load(MONGREL_PLUGINS_DIR, ["rails"]) Mongrel::Command::Registry.instance.run ARGV -- cgit v1.2.3-24-ge0c7