diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-11-07 10:42:52 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-11-07 10:42:52 +0000 |
commit | e85e58f7a9a0989e1f729ad2c1d453fa438155ac (patch) | |
tree | d01fbffe012414a5387364c6c846c8f4a4e44d61 /railties/lib/commands/servers/webrick.rb | |
parent | 5ca8b5fca42ca09bdaadfc7c985fbec9c2fbafa5 (diff) | |
download | rails-e85e58f7a9a0989e1f729ad2c1d453fa438155ac.tar.gz rails-e85e58f7a9a0989e1f729ad2c1d453fa438155ac.tar.bz2 rails-e85e58f7a9a0989e1f729ad2c1d453fa438155ac.zip |
Added default lighttpd config in config/lighttpd.conf and added a default runner for lighttpd in script/server (works like script/server, but using lighttpd and FastCGI). It will use lighttpd if available, otherwise WEBrick. You can force either or using 'script/server lighttpd' or 'script/server webrick' [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2913 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/commands/servers/webrick.rb')
-rw-r--r-- | railties/lib/commands/servers/webrick.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/railties/lib/commands/servers/webrick.rb b/railties/lib/commands/servers/webrick.rb new file mode 100644 index 0000000000..db8e8b3d93 --- /dev/null +++ b/railties/lib/commands/servers/webrick.rb @@ -0,0 +1,59 @@ +require 'webrick' +require 'optparse' + +OPTIONS = { + :port => 3000, + :ip => "0.0.0.0", + :environment => (ENV['RAILS_ENV'] || "development").dup, + :server_root => File.expand_path(RAILS_ROOT + "/public/"), + :server_type => WEBrick::SimpleServer, + :charset => "UTF-8", + :mime_types => WEBrick::HTTPUtils::DefaultMimeTypes +} + +ARGV.options do |opts| + script_name = File.basename($0) + opts.banner = "Usage: ruby #{script_name} [options]" + + opts.separator "" + + opts.on("-p", "--port=port", Integer, + "Runs Rails on the specified port.", + "Default: 3000") { |OPTIONS[:port]| } + opts.on("-b", "--binding=ip", String, + "Binds Rails to the specified ip.", + "Default: 0.0.0.0") { |OPTIONS[:ip]| } + opts.on("-e", "--environment=name", String, + "Specifies the environment to run this server under (test/development/production).", + "Default: development") { |OPTIONS[:environment]| } + opts.on("-m", "--mime-types=filename", String, + "Specifies an Apache style mime.types configuration file to be used for mime types", + "Default: none") { |mime_types_file| OPTIONS[:mime_types] = WEBrick::HTTPUtils::load_mime_types(mime_types_file) } + + opts.on("-d", "--daemon", + "Make Rails run as a Daemon (only works if fork is available -- meaning on *nix)." + ) { OPTIONS[:server_type] = WEBrick::Daemon } + + opts.on("-c", "--charset=charset", String, + "Set default charset for output.", + "Default: UTF-8") { |OPTIONS[:charset]| } + + opts.separator "" + + opts.on("-h", "--help", + "Show this help message.") { puts opts; exit } + + opts.parse! +end + +ENV["RAILS_ENV"] = OPTIONS[:environment] +RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV) + +require RAILS_ROOT + "/config/environment" +require 'webrick_server' + +OPTIONS['working_directory'] = File.expand_path(RAILS_ROOT) + +puts "=> Rails application started on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}" +puts "=> Ctrl-C to shutdown server; call with --help for options" if OPTIONS[:server_type] == WEBrick::SimpleServer +DispatchServlet.dispatch(OPTIONS) |