From b8f8776f0cffc1b73719f16513a5721d77b19186 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 16 Dec 2004 15:45:55 +0000 Subject: 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 --- railties/CHANGELOG | 8 +++--- railties/README | 2 +- railties/Rakefile | 4 +-- railties/bin/server | 49 ++++++++++++++++++++++++++++++++++++ railties/configs/apache.conf | 2 -- railties/dispatches/dispatch.servlet | 49 ------------------------------------ 6 files changed, 56 insertions(+), 58 deletions(-) create mode 100644 railties/bin/server delete mode 100644 railties/dispatches/dispatch.servlet diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 1d1806376b..e8c4d9acad 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,12 +1,14 @@ *CVS* +* Renamed public/dispatch.servlet to script/server -- it wasn't really dispatching anyway as its delegating calls to public/dispatch.rb + * Renamed AbstractApplicationController and abstract_application.rb to ApplicationController and application.rb, so that it will be possible for the framework to automatically pick up on app/views/layouts/application.rhtml and app/helpers/application.rb * Added script/envcon that makes it even easier to start an IRB session for interacting with the domain model. Run with no-args to see help. -* Added breakpoint support by default to the WEBrick dispatcher. This means that you can break out of execution at any point in +* Added breakpoint support through the script/breakpointer client. This means that you can break out of execution at any point in the code, investigate and change the model, AND then resume execution! Example: class WeblogController < ActionController::Base @@ -16,8 +18,8 @@ end end - So the controller will accept the action, run the first line, then present you with a IRB prompt in the WEBrick window (you shouldn't - run as daemon when you want to use this). Here you can do things like: + So the controller will accept the action, run the first line, then present you with a IRB prompt in the breakpointer window. + Here you can do things like: Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint' diff --git a/railties/README b/railties/README index c8446e4e55..4d58c3276c 100644 --- a/railties/README +++ b/railties/README @@ -38,7 +38,7 @@ link:files/vendor/actionpack/README.html. == Getting started -1. Run the WEBrick servlet: ruby public/dispatch.servlet +1. Run the WEBrick servlet: ruby script/server (run with --help for options) 2. Go to http://localhost:3000/ and get "Congratulations, you've put Ruby on Rails!" 3. Follow the guidelines on the "Congratulations, you're on Rails!" screen diff --git a/railties/Rakefile b/railties/Rakefile index 088bfbe74e..dc3f7a9679 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -21,7 +21,7 @@ TEST_DIRS = %w( fixtures unit functional mocks mocks/development mocks/testing LOG_FILES = %w( apache.log development.log test.log production.log ) HTML_FILES = %w( 404.html 500.html index.html ) -BIN_FILES = %w( generate breakpointer envcon ) +BIN_FILES = %w( generate breakpointer envcon server ) GENERATORS = %w( controller mailer model scaffold ) VENDOR_LIBS = %w( actionpack activerecord actionmailer railties ) @@ -109,8 +109,6 @@ task :copy_dispatches do cp "dispatches/dispatch.fcgi", "#{PKG_DESTINATION}/public/dispatch.fcgi" chmod 0755, "#{PKG_DESTINATION}/public/dispatch.fcgi" - cp "dispatches/dispatch.servlet", "#{PKG_DESTINATION}/public/dispatch.servlet" - cp "bin/envcon", "#{PKG_DESTINATION}/script/envcon" chmod 0755, "#{PKG_DESTINATION}/script/envcon" end 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 diff --git a/railties/configs/apache.conf b/railties/configs/apache.conf index 2edf69beb7..1ba845cdee 100755 --- a/railties/configs/apache.conf +++ b/railties/configs/apache.conf @@ -9,8 +9,6 @@ RewriteEngine On # Change extension from .cgi to .fcgi to switch to FCGI and to .rb to switch to mod_ruby RewriteBase /dispatch.cgi -RewriteRule ^dispatch.servlet$ / [R] - # Enable this rewrite rule to point to the controller/action that should serve root. # RewriteRule ^$ /controller/action diff --git a/railties/dispatches/dispatch.servlet b/railties/dispatches/dispatch.servlet deleted file mode 100644 index a1fa403a67..0000000000 --- a/railties/dispatches/dispatch.servlet +++ /dev/null @@ -1,49 +0,0 @@ -#!/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 -- cgit v1.2.3