diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-02-14 19:28:05 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-02-14 19:28:05 +0000 |
commit | 6f3c5f67870a625b8be4de6e34e8d0d2f5d2b5e3 (patch) | |
tree | 3da8d75101aabe3c1d90d0582505ec1480c9d885 /railties/lib/rails/commands/server.rb | |
parent | 77bf78b3b78a41d4f2f6e733f5c9c00608c0adba (diff) | |
parent | a1b60696e2b13cbe94d748444cc0da37b190fbb8 (diff) | |
download | rails-6f3c5f67870a625b8be4de6e34e8d0d2f5d2b5e3.tar.gz rails-6f3c5f67870a625b8be4de6e34e8d0d2f5d2b5e3.tar.bz2 rails-6f3c5f67870a625b8be4de6e34e8d0d2f5d2b5e3.zip |
Merge remote branch 'mainstream/master'
Conflicts:
railties/README
railties/guides/source/active_support_core_extensions.textile
railties/guides/source/getting_started.textile
railties/lib/generators/rails/app/templates/README
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 |