Skip to content
Browse files

Made script/server work with -e and -d when using Mongrel [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5578 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 30e5436 commit b93e4692b26d348f229095d87fba02fb1efdbe9f @dhh dhh committed Nov 19, 2006
Showing with 37 additions and 44 deletions.
  1. +1 −3 railties/CHANGELOG
  2. +1 −1 railties/lib/commands/servers/lighttpd.rb
  3. +35 −40 railties/lib/commands/servers/mongrel.rb
View
4 railties/CHANGELOG
@@ -1,8 +1,6 @@
*1.2.0 RC1* (November 8th, 2006)
-* Use custom mime file for script/server mongrel if config/mime.yml exists. Pass --mime=other/path for a custom mime file. [Rick Olson]
-
-* Add custom mime type file for mongrel. config/mime.yml is added with generated apps from the rails command. [Rick Olson]
+* Made script/server work with -e and -d when using Mongrel [DHH]
* Update to Prototype 1.5.0_rc2 [5550] which makes it work in Opera again [Thomas Fuchs]
View
2 railties/lib/commands/servers/lighttpd.rb
@@ -62,7 +62,7 @@
default_port, default_ip = 3000, '0.0.0.0'
port = config.scan(/^\s*server.port\s*=\s*(\d+)/).first rescue default_port
ip = config.scan(/^\s*server.bind\s*=\s*"([^"]+)"/).first rescue default_ip
-puts "=> Rails application started on http://#{ip || default_ip}:#{port || default_port}"
+puts "=> Rails application starting on http://#{ip || default_ip}:#{port || default_port}"
tail_thread = nil
View
75 railties/lib/commands/servers/mongrel.rb
@@ -6,57 +6,52 @@
exit 1
end
-require 'initializer'
-Rails::Initializer.run(:initialize_logger)
-
require 'optparse'
-detach = false
-ip = nil
-port = nil
-mime = 'config/mime.yml'
-
-ARGV.clone.options do |opt|
- opt.on("-p", "--port=port", Integer,
- "Runs Rails on the specified port.",
- "Default: 3000") { |p| port = p }
- opt.on("-a", "--address=ip", String,
- "Binds Rails to the specified ip.",
- "Default: 0.0.0.0") { |i| ip = i }
- opt.on("-m", "--mime=path", String,
- "Path to custom mime file.",
- "Default: config/mime.yml (if it exists)") { |m| mime = m }
- opt.on('-h', '--help', 'Show this message.') { puts opt; exit 0 }
- opt.on('-d', '-d', 'Call with -d to detach') { detach = true }
- opt.parse!
-end
+OPTIONS = {
+ :port => 3000,
+ :ip => "0.0.0.0",
+ :environment => (ENV['RAILS_ENV'] || "development").dup,
+ :detach => false
+}
+
+ARGV.clone.options do |opts|
+ opts.on("-p", "--port=port", Integer, "Runs Rails on the specified port.", "Default: 3000") { |v| OPTIONS[:port] = v }
+ opts.on("-b", "--binding=ip", String, "Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v| OPTIONS[:ip] = v }
+ opts.on("-d", "--daemon", "Make server run as a Daemon.") { OPTIONS[:detach] = true }
+ opts.on("-e", "--environment=name", String,
+ "Specifies the environment to run this server under (test/development/production).",
+ "Default: development") { |v| OPTIONS[:environment] = v }
-default_port, default_ip = 3000, '0.0.0.0'
-puts "=> Rails application started on http://#{ip || default_ip}:#{port || default_port}"
+ opts.separator ""
-log_file = Pathname.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log").cleanpath
+ opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
+
+ opts.parse!
+end
-tail_thread = nil
+puts "=> Rails application starting on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
+
+if OPTIONS[:detach]
+ `mongrel_rails start -d -p #{OPTIONS[:port]} -a #{OPTIONS[:ip]} -e #{OPTIONS[:environment]}`
+else
+ require 'initializer'
+ Rails::Initializer.run(:initialize_logger)
-if !detach
puts "=> Call with -d to detach"
puts "=> Ctrl-C to shutdown server"
- detach = false
- tail_thread = tail(log_file)
-end
+ tail_thread = tail(Pathname.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log").cleanpath)
-trap(:INT) { exit }
+ trap(:INT) { exit }
-if File.exist?(File.join(RAILS_ROOT, mime)) && !ARGV.any? { |a| a =~ /^--?m/ }
- ARGV << "--mime=#{mime}"
-end
+ begin
+ silence_warnings do
+ ARGV = [ "start", "-p", OPTIONS[:port].to_s, "-a", OPTIONS[:ip].to_s, "-e", OPTIONS[:environment] ]
+ end
-begin
- ARGV.unshift("start")
- load 'mongrel_rails'
-ensure
- unless detach
+ load("mongrel_rails")
+ ensure
tail_thread.kill if tail_thread
puts 'Exiting'
end
-end
+end

0 comments on commit b93e469

Please sign in to comment.
Something went wrong with that request. Please try again.