From 5c13c5dd9d92c60223829881b9835ee9fb02f400 Mon Sep 17 00:00:00 2001 From: zedshaw Date: Thu, 2 Mar 2006 03:54:32 +0000 Subject: Commands now converted to new plugin setup. Implemented initial plugin loading option -L. git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@67 19e92222-5c0b-0410-8929-a290d50e31e9 --- bin/mongrel_rails | 33 +++++++++++++++++++-------------- bin/mongrel_rails_service | 8 ++++---- 2 files changed, 23 insertions(+), 18 deletions(-) (limited to 'bin') diff --git a/bin/mongrel_rails b/bin/mongrel_rails index c9051fe..c78895d 100644 --- a/bin/mongrel_rails +++ b/bin/mongrel_rails @@ -3,21 +3,22 @@ require 'mongrel/rails' class Start < Mongrel::Plugin "/commands" - include Mongrel::Command::Command + include Mongrel::Command::Base def configure options [ - ["-e", "--environment ENV", "Rails environment to run as", :@environment, ENV['RAILS_ENV'] || "development"], - ["-d", "--daemonize", "Whether to run in the background or not", :@daemon, false], - ['-p', '--port PORT', "Which port to bind to", :@port, 3000], - ['-a', '--address ADDR', "Address to bind to", :@address, "0.0.0.0"], - ['-l', '--log FILE', "Where to write log messages", :@log_file, "log/mongrel.log"], - ['-P', '--pid FILE', "Where to write the PID", :@pid_file, "log/mongrel.pid"], - ['-n', '--num-procs INT', "Number of processor threads to use", :@num_procs, 20], - ['-t', '--timeout SECONDS', "Timeout all requests after SECONDS time", :@timeout, 120], - ['-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"], + ["-e", "--environment ENV", "Rails environment to run as", :@environment, ENV['RAILS_ENV'] || "development"], + ["-d", "--daemonize", "Whether to run in the background or not", :@daemon, false], + ['-p', '--port PORT', "Which port to bind to", :@port, 3000], + ['-a', '--address ADDR', "Address to bind to", :@address, "0.0.0.0"], + ['-l', '--log FILE', "Where to write log messages", :@log_file, "log/mongrel.log"], + ['-P', '--pid FILE', "Where to write the PID", :@pid_file, "log/mongrel.pid"], + ['-n', '--num-procs INT', "Number of processor threads to use", :@num_procs, 20], + ['-t', '--timeout SECONDS', "Timeout all requests after SECONDS time", :@timeout, 120], + ['-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 @@ -33,9 +34,12 @@ 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 + def daemonize # save this for later since daemonize will hose it if @daemon and RUBY_PLATFORM !~ /mswin/ @@ -120,6 +124,7 @@ class Start < Mongrel::Plugin "/commands" end def run + Mongrel::PluginManager.instance.load(@load_from) if @load_from daemonize rails = configure_rails start_mongrel(rails) @@ -141,7 +146,7 @@ end class Stop < Mongrel::Plugin "/commands" - include Mongrel::Command::Command + include Mongrel::Command::Base def configure options [ @@ -176,7 +181,7 @@ end class Restart < Mongrel::Plugin "/commands" - include Mongrel::Command::Command + include Mongrel::Command::Base def configure options [ diff --git a/bin/mongrel_rails_service b/bin/mongrel_rails_service index 8609890..a82546e 100644 --- a/bin/mongrel_rails_service +++ b/bin/mongrel_rails_service @@ -31,7 +31,7 @@ module GenericCommand end class Install < Mongrel::Plugin "/commands" - include Mongrel::Command::Command + include Mongrel::Command::Base # Default every option to nil so only the defined ones get passed to service # (which will override ServiceCommand defaults). @@ -175,7 +175,7 @@ class Install < Mongrel::Plugin "/commands" end class Delete < Mongrel::Plugin "/commands" - include Mongrel::Command::Command + include Mongrel::Command::Base include GenericCommand def run @@ -194,7 +194,7 @@ class Delete < Mongrel::Plugin "/commands" end class Start < Mongrel::Plugin "/commands" - include Mongrel::Command::Command + include Mongrel::Command::Base include GenericCommand def run @@ -219,7 +219,7 @@ class Start < Mongrel::Plugin "/commands" end class Stop < Mongrel::Plugin "/commands" - include Mongrel::Command::Command + include Mongrel::Command::Base include GenericCommand def run -- cgit v1.2.3-24-ge0c7