about summary refs log tree commit homepage
path: root/bin
diff options
context:
space:
mode:
authorzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-03-26 23:57:11 +0000
committerzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-03-26 23:57:11 +0000
commit4d9966ee00b597cff3b58c851aef65c3801d9077 (patch)
treef845b065e891869fe6df47fd6ec286146f953d8d /bin
parentf2b53a3a4b1ddacac4fc18ccbe2b016194a50777 (diff)
downloadunicorn-4d9966ee00b597cff3b58c851aef65c3801d9077.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@123 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'bin')
-rw-r--r--bin/mongrel_rails9
1 files changed, 8 insertions, 1 deletions
diff --git a/bin/mongrel_rails b/bin/mongrel_rails
index 23121d8..74d56be 100644
--- a/bin/mongrel_rails
+++ b/bin/mongrel_rails
@@ -22,6 +22,7 @@ class Start < GemPlugin::Plugin "/commands"
       ['-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"],
       ['-B', '--debug', "Enable debugging mode", :@debug, false],
+      ['-C', '--config PATH', "Use a config file", :@config_file, nil]
     ]
   end
   
@@ -36,18 +37,24 @@ class Start < GemPlugin::Plugin "/commands"
     valid_dir? File.dirname(@pid_file), "Path to pid file not valid: #@pid_file"
     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_exists? @config_file, "Config file not there: #@config_file" if @config_file
     return @valid
   end
 
   def run
 
+    # command line setting override config file settings
     settings = { :host => @address,  :port => @port, :cwd => @cwd,
       :log_file => @log_file, :pid_file => @pid_file, :environment => @environment,
       :docroot => @docroot, :mime_map => @mime_map, :daemon => @daemon,
       :debug => @debug, :includes => ["mongrel"]
     }
 
+    if @config_file
+      STDERR.puts "** Loading settings from #{@config_file} (command line options override)."
+      conf = YAML.load_file(@config_file)
+      settings = conf.merge(settings)
+    end
     
     config = Mongrel::Rails::RailsConfigurator.new(settings) do
       log "Starting Mongrel in #{settings[:environment]} mode at #{settings[:host]}:#{settings[:port]}"