aboutsummaryrefslogtreecommitdiffstats
path: root/railties/bin
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-09-29 12:18:51 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-09-29 12:18:51 +0000
commit0a0ac868453e9d8d9ee1dac6a7eb274772235b05 (patch)
tree1db7e1fce4d2c62f97c204ef72e7898c5263c82a /railties/bin
parent070d218c479c8cbb41e78f599110f0ea1cf0343a (diff)
downloadrails-0a0ac868453e9d8d9ee1dac6a7eb274772235b05.tar.gz
rails-0a0ac868453e9d8d9ee1dac6a7eb274772235b05.tar.bz2
rails-0a0ac868453e9d8d9ee1dac6a7eb274772235b05.zip
Removed all the scripts in script/* and replaced it with one generic portal: script/run
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2411 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/bin')
-rw-r--r--railties/bin/benchmarker19
-rw-r--r--railties/bin/breakpointer3
-rw-r--r--railties/bin/breakpointer_for_gem4
-rw-r--r--railties/bin/console23
-rw-r--r--railties/bin/console_sandbox0
-rw-r--r--railties/bin/destroy7
-rwxr-xr-xrailties/bin/generate7
-rw-r--r--railties/bin/listener86
-rw-r--r--railties/bin/profiler35
-rwxr-xr-xrailties/bin/run3
-rw-r--r--railties/bin/runner28
-rw-r--r--railties/bin/server59
-rw-r--r--railties/bin/tracker69
-rw-r--r--railties/bin/update5
14 files changed, 3 insertions, 345 deletions
diff --git a/railties/bin/benchmarker b/railties/bin/benchmarker
deleted file mode 100644
index b07ddcfcb2..0000000000
--- a/railties/bin/benchmarker
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/local/bin/ruby
-
-if ARGV.empty?
- puts "Usage: benchmarker times 'Person.expensive_way' 'Person.another_expensive_way' ..."
- exit
-end
-
-require File.dirname(__FILE__) + '/../config/environment'
-require 'benchmark'
-include Benchmark
-
-# Don't include compilation in the benchmark
-ARGV[1..-1].each { |expression| eval(expression) }
-
-bm(6) do |x|
- ARGV[1..-1].each_with_index do |expression, idx|
- x.report("##{idx + 1}") { ARGV[0].to_i.times { eval(expression) } }
- end
-end \ No newline at end of file
diff --git a/railties/bin/breakpointer b/railties/bin/breakpointer
deleted file mode 100644
index 4ac3e7c3c9..0000000000
--- a/railties/bin/breakpointer
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/local/bin/ruby
-$LOAD_PATH << File.dirname(__FILE__) + '/../vendor/railties/lib'
-require 'breakpoint_client'
diff --git a/railties/bin/breakpointer_for_gem b/railties/bin/breakpointer_for_gem
deleted file mode 100644
index 1366641582..0000000000
--- a/railties/bin/breakpointer_for_gem
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/local/bin/ruby
-require 'rubygems'
-require_gem 'rails'
-require 'breakpoint_client'
diff --git a/railties/bin/console b/railties/bin/console
deleted file mode 100644
index eece24a9ca..0000000000
--- a/railties/bin/console
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/local/bin/ruby
-irb = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb'
-
-require 'optparse'
-options = { :sandbox => false, :irb => irb }
-OptionParser.new do |opt|
- opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |options[:sandbox]| }
- opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |options[:irb]| }
- opt.parse!(ARGV)
-end
-
-libs = " -r irb/completion"
-libs << " -r #{File.dirname(__FILE__)}/../config/environment"
-libs << " -r console_sandbox" if options[:sandbox]
-
-ENV['RAILS_ENV'] = ARGV.first || 'development'
-if options[:sandbox]
- puts "Loading #{ENV['RAILS_ENV']} environment in sandbox."
- puts "Any modifications you make will be rolled back on exit."
-else
- puts "Loading #{ENV['RAILS_ENV']} environment."
-end
-exec "#{options[:irb]} #{libs} --prompt-mode simple"
diff --git a/railties/bin/console_sandbox b/railties/bin/console_sandbox
deleted file mode 100644
index e69de29bb2..0000000000
--- a/railties/bin/console_sandbox
+++ /dev/null
diff --git a/railties/bin/destroy b/railties/bin/destroy
deleted file mode 100644
index f9d9d181a4..0000000000
--- a/railties/bin/destroy
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/local/bin/ruby
-require File.dirname(__FILE__) + '/../config/environment'
-require 'rails_generator'
-require 'rails_generator/scripts/destroy'
-
-ARGV.shift if ['--help', '-h'].include?(ARGV[0])
-Rails::Generator::Scripts::Destroy.new.run(ARGV)
diff --git a/railties/bin/generate b/railties/bin/generate
deleted file mode 100755
index 43bcfd0cb1..0000000000
--- a/railties/bin/generate
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/local/bin/ruby
-require File.dirname(__FILE__) + '/../config/environment'
-require 'rails_generator'
-require 'rails_generator/scripts/generate'
-
-ARGV.shift if ['--help', '-h'].include?(ARGV[0])
-Rails::Generator::Scripts::Generate.new.run(ARGV)
diff --git a/railties/bin/listener b/railties/bin/listener
deleted file mode 100644
index 421c453f23..0000000000
--- a/railties/bin/listener
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/local/bin/ruby
-
-require 'stringio'
-require 'fileutils'
-require 'fcgi_handler'
-
-def message(s)
- $stderr.puts "listener: #{s}" if ENV && ENV["DEBUG_GATEWAY"]
-end
-
-class RemoteCGI < CGI
- attr_accessor :stdinput, :stdoutput, :env_table
- def initialize(env_table, input = nil, output = nil)
- self.env_table = env_table
- self.stdinput = input || StringIO.new
- self.stdoutput = output || StringIO.new
- super()
- end
-
- def out(stream) # Ignore the requested output stream
- super(stdoutput)
- end
-end
-
-class Listener
- include DRbUndumped
-
- def initialize(timeout, socket_path)
- @socket = File.expand_path(socket_path)
- @mutex = Mutex.new
- @active = false
- @timeout = timeout
-
- @handler = RailsFCGIHandler.new
- @handler.extend DRbUndumped
-
- message 'opening socket'
- DRb.start_service("drbunix:#{@socket}", self)
-
- message 'entering process loop'
- @handler.process! self
- end
-
- def each_cgi(&cgi_block)
- @cgi_block = cgi_block
- message 'entering idle loop'
- loop do
- sleep @timeout rescue nil
- die! unless @active
- @active = false
- end
- end
-
- def process(env, input)
- message 'received request'
- @mutex.synchronize do
- @active = true
-
- message 'creating input stream'
- input_stream = StringIO.new(input)
- message 'building CGI instance'
- cgi = RemoteCGI.new(eval(env), input_stream)
-
- message 'yielding to fcgi handler'
- @cgi_block.call cgi
- message 'yield finished -- sending output'
-
- cgi.stdoutput.seek(0)
- output = cgi.stdoutput.read
-
- return output
- end
- end
-
- def die!
- message 'shutting down'
- DRb.stop_service
- FileUtils.rm_f @socket
- Kernel.exit 0
- end
-end
-
-socket_path = ARGV.shift
-timeout = (ARGV.shift || 90).to_i
-
-Listener.new(timeout, socket_path) \ No newline at end of file
diff --git a/railties/bin/profiler b/railties/bin/profiler
deleted file mode 100644
index d84c8b739f..0000000000
--- a/railties/bin/profiler
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/local/bin/ruby
-if ARGV.empty?
- $stderr.puts "Usage: profiler 'Person.expensive_method(10)' [times]"
- exit(1)
-end
-
-# Keep the expensive require out of the profile.
-$stderr.puts 'Loading Rails...'
-require File.dirname(__FILE__) + '/../config/environment'
-
-# Define a method to profile.
-if ARGV[1] and ARGV[1].to_i > 1
- eval "def profile_me() #{ARGV[1]}.times { #{ARGV[0]} } end"
-else
- eval "def profile_me() #{ARGV[0]} end"
-end
-
-# Use the ruby-prof extension if available. Fall back to stdlib profiler.
-begin
- require 'prof'
- $stderr.puts 'Using the ruby-prof extension.'
- Prof.clock_mode = Prof::GETTIMEOFDAY
- Prof.start
- profile_me
- results = Prof.stop
- require 'rubyprof_ext'
- Prof.print_profile(results, $stderr)
-rescue LoadError
- require 'profiler'
- $stderr.puts 'Using the standard Ruby profiler.'
- Profiler__.start_profile
- profile_me
- Profiler__.stop_profile
- Profiler__.print_profile($stderr)
-end
diff --git a/railties/bin/run b/railties/bin/run
new file mode 100755
index 0000000000..5490bc9336
--- /dev/null
+++ b/railties/bin/run
@@ -0,0 +1,3 @@
+#!/usr/local/bin/ruby
+require File.dirname(__FILE__) + '/../config/boot'
+require "commands" \ No newline at end of file
diff --git a/railties/bin/runner b/railties/bin/runner
deleted file mode 100644
index c319bfe658..0000000000
--- a/railties/bin/runner
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'optparse'
-
-options = { :environment => "development" }
-
-ARGV.options do |opts|
- script_name = File.basename($0)
- opts.banner = "Usage: runner 'puts Person.find(1).name' [options]"
-
- opts.separator ""
-
- opts.on("-e", "--environment=name", String,
- "Specifies the environment for the runner to operate under (test/development/production).",
- "Default: development") { |options[:environment]| }
-
- opts.separator ""
-
- opts.on("-h", "--help",
- "Show this help message.") { puts opts; exit }
-
- opts.parse!
-end
-
-ENV["RAILS_ENV"] = options[:environment]
-
-#!/usr/local/bin/ruby
-
-require File.dirname(__FILE__) + '/../config/environment'
-eval(ARGV.first) \ No newline at end of file
diff --git a/railties/bin/server b/railties/bin/server
deleted file mode 100644
index ff38c6f7af..0000000000
--- a/railties/bin/server
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/local/bin/ruby
-
-require 'webrick'
-require 'optparse'
-
-OPTIONS = {
- :port => 3000,
- :ip => "0.0.0.0",
- :environment => "development",
- :server_root => File.expand_path(File.dirname(__FILE__) + "/../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]
-require File.dirname(__FILE__) + "/../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)
diff --git a/railties/bin/tracker b/railties/bin/tracker
deleted file mode 100644
index 859c9fa0e0..0000000000
--- a/railties/bin/tracker
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/local/bin/ruby
-
-require 'drb'
-require 'thread'
-
-def message(s)
- $stderr.puts "tracker: #{s}" if ENV && ENV["DEBUG_GATEWAY"]
-end
-
-class Tracker
- include DRbUndumped
-
- def initialize(instances, socket_path)
- @instances = instances
- @socket = File.expand_path(socket_path)
- @active = false
-
- @listeners = []
- @instances.times { @listeners << Mutex.new }
-
- message "using #{@listeners.length} listeners"
- message "opening socket at #{@socket}"
-
- @service = DRb.start_service("drbunix://#{@socket}", self)
- end
-
- def with_listener
- message "listener requested"
-
- mutex = has_lock = index = nil
- 3.times do
- @listeners.each_with_index do |mutex, index|
- has_lock = mutex.try_lock
- break if has_lock
- end
- break if has_lock
- sleep 0.05
- end
-
- if has_lock
- message "obtained listener #{index}"
- @active = true
- begin yield index
- ensure
- mutex.unlock
- message "released listener #{index}"
- end
- else
- message "dropping request because no listeners are available!"
- end
- end
-
- def background(check_interval = nil)
- if check_interval
- loop do
- sleep check_interval
- message "Idle for #{check_interval}, shutting down" unless @active
- @active = false
- Kernel.exit 0
- end
- else DRb.thread.join
- end
- end
-end
-
-socket_path = ARGV.shift
-instances = ARGV.shift.to_i
-t = Tracker.new(instances, socket_path)
-t.background(ARGV.first ? ARGV.shift.to_i : 90) \ No newline at end of file
diff --git a/railties/bin/update b/railties/bin/update
deleted file mode 100644
index 430d325b07..0000000000
--- a/railties/bin/update
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/local/bin/ruby
-require File.dirname(__FILE__) + '/../config/environment'
-require 'rails_generator'
-require 'rails_generator/scripts/update'
-Rails::Generator::Scripts::Update.new.run(ARGV)