diff options
author | Mikel Lindsaar <raasdnil@gmail.com> | 2010-03-11 22:07:48 +1100 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-03-11 22:07:48 +1100 |
commit | 965fe59bff249ad91131a444e1fbd63dc4411db3 (patch) | |
tree | ec2d54d5eaad9e32bce1758e6a67c364279bbd39 /railties/lib/rails/commands/server.rb | |
parent | 79f02a473cb6aef00003745f23802314c8c89e7d (diff) | |
parent | 4adcbb6b2d6cef49ac28df4254ac74e09f14dcf7 (diff) | |
download | rails-965fe59bff249ad91131a444e1fbd63dc4411db3.tar.gz rails-965fe59bff249ad91131a444e1fbd63dc4411db3.tar.bz2 rails-965fe59bff249ad91131a444e1fbd63dc4411db3.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'railties/lib/rails/commands/server.rb')
-rw-r--r-- | railties/lib/rails/commands/server.rb | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index b21ae2a17b..c57660c0d1 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -6,20 +6,21 @@ module Rails class Server < ::Rack::Server class Options def parse!(args) - options = {} - args = args.dup + args, options = args.dup, {} + opt_parser = OptionParser.new do |opts| + opts.banner = "Usage: rails server [options]" opts.on("-p", "--port=port", Integer, - "Runs Rails on the specified port.", "Default: #{options[:Port]}") { |v| options[:Port] = v } + "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: #{options[:Host]}") { |v| options[:Host] = v } + "Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v| options[:Host] = v } opts.on("-c", "--config=file", String, "Use custom rackup configuration file") { |v| options[:config] = v } opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:daemonize] = true } opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { options[:debugger] = true } opts.on("-e", "--environment=name", String, "Specifies the environment to run this server under (test/development/production).", - "Default: #{options[:environment]}") { |v| options[:environment] = v } + "Default: development") { |v| options[:environment] = v } opts.separator "" @@ -33,13 +34,20 @@ module Rails end end + def initialize(*) + super + set_environment + end + def opt_parser Options.new end - def start - ENV["RAILS_ENV"] = options[:environment] + def set_environment + ENV["RAILS_ENV"] ||= options[:environment] + end + def start puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}" puts "=> Rails #{Rails.version} application starting in #{Rails.env} on http://#{options[:Host]}:#{options[:Port]}" puts "=> Call with -d to detach" unless options[:daemonize] @@ -48,7 +56,9 @@ module Rails super ensure - puts 'Exiting' unless options[:daemonize] + # The '-h' option calls exit before @options is set. + # If we call 'options' with it unset, we get double help banners. + puts 'Exiting' unless @options && options[:daemonize] end def middleware |