aboutsummaryrefslogtreecommitdiffstats
path: root/railties/bin/server
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-12-16 15:45:55 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-12-16 15:45:55 +0000
commitb8f8776f0cffc1b73719f16513a5721d77b19186 (patch)
treeb02a65c7c9e37a8f031fecbd92b19a8a7afc4bd9 /railties/bin/server
parent4fb6ed4c1c35ba055df36602e3d75b68e7fcb212 (diff)
downloadrails-b8f8776f0cffc1b73719f16513a5721d77b19186.tar.gz
rails-b8f8776f0cffc1b73719f16513a5721d77b19186.tar.bz2
rails-b8f8776f0cffc1b73719f16513a5721d77b19186.zip
Renamed public/dispatch.servlet to script/server -- it wasn't really dispatching anyway as its delegating calls to public/dispatch.rb
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@186 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/bin/server')
-rw-r--r--railties/bin/server49
1 files changed, 49 insertions, 0 deletions
diff --git a/railties/bin/server b/railties/bin/server
new file mode 100644
index 0000000000..a1fa403a67
--- /dev/null
+++ b/railties/bin/server
@@ -0,0 +1,49 @@
+#!/usr/local/bin/ruby
+
+require 'webrick'
+require 'optparse'
+
+OPTIONS = {
+ :port => 3000,
+ :ip => "127.0.0.1",
+ :environment => "development",
+ :server_root => File.expand_path(File.dirname(__FILE__)),
+ :server_type => WEBrick::SimpleServer
+}
+
+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: 127.0.0.1") { |OPTIONS[:ip]| }
+ opts.on("-i", "--index=controller", String,
+ "Specifies an index controller that requests for root will go to (instead of congratulations screen)."
+ ) { |OPTIONS[:index_controller]| }
+ opts.on("-e", "--environment=name", String,
+ "Specifies the environment to run this server under (test/development/production).",
+ "Default: development") { |OPTIONS[:environment]| }
+ 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.separator ""
+
+ opts.on("-h", "--help",
+ "Show this help message.") { puts opts; exit }
+
+ opts.parse!
+end
+
+ENV["RAILS_ENV"] = OPTIONS[:environment]
+require File.dirname(__FILE__) + "/../config/environment"
+require 'webrick_server'
+
+puts "=> Rails application started on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
+DispatchServlet.dispatch(OPTIONS) \ No newline at end of file