diff options
author | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-12-03 19:30:35 +0100 |
---|---|---|
committer | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-12-03 19:30:35 +0100 |
commit | ccb96f2297e8783165cba764e9b5d51e1a15ff87 (patch) | |
tree | 3229e6fdddc42054615514d843c555e341003033 /railties/lib/commands/servers | |
parent | fb2325e35855d62abd2c76ce03feaa3ca7992e4f (diff) | |
parent | 761a633a9c0a45d76ef3ed10da97e3696c3ded79 (diff) | |
download | rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.tar.gz rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.tar.bz2 rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.zip |
Merge commit 'origin/master' into savepoints
Conflicts:
activerecord/lib/active_record/fixtures.rb
activerecord/test/cases/defaults_test.rb
Diffstat (limited to 'railties/lib/commands/servers')
-rw-r--r-- | railties/lib/commands/servers/base.rb | 31 | ||||
-rw-r--r-- | railties/lib/commands/servers/lighttpd.rb | 94 | ||||
-rw-r--r-- | railties/lib/commands/servers/mongrel.rb | 69 | ||||
-rw-r--r-- | railties/lib/commands/servers/new_mongrel.rb | 16 | ||||
-rw-r--r-- | railties/lib/commands/servers/thin.rb | 25 | ||||
-rw-r--r-- | railties/lib/commands/servers/webrick.rb | 66 |
6 files changed, 0 insertions, 301 deletions
diff --git a/railties/lib/commands/servers/base.rb b/railties/lib/commands/servers/base.rb deleted file mode 100644 index 23be169a8d..0000000000 --- a/railties/lib/commands/servers/base.rb +++ /dev/null @@ -1,31 +0,0 @@ -def tail(log_file) - cursor = File.size(log_file) - last_checked = Time.now - tail_thread = Thread.new do - File.open(log_file, 'r') do |f| - loop do - f.seek cursor - if f.mtime > last_checked - last_checked = f.mtime - contents = f.read - cursor += contents.length - print contents - end - sleep 1 - end - end - end - tail_thread -end - -def start_debugger - begin - require_library_or_gem 'ruby-debug' - Debugger.start - Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings) - puts "=> Debugger enabled" - rescue Exception - puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'" - exit - end -end
\ No newline at end of file diff --git a/railties/lib/commands/servers/lighttpd.rb b/railties/lib/commands/servers/lighttpd.rb deleted file mode 100644 index c9d13e86f3..0000000000 --- a/railties/lib/commands/servers/lighttpd.rb +++ /dev/null @@ -1,94 +0,0 @@ -require 'rbconfig' -require 'commands/servers/base' - -unless RUBY_PLATFORM !~ /mswin/ && !silence_stderr { `lighttpd -version` }.blank? - puts "PROBLEM: Lighttpd is not available on your system (or not in your path)" - exit 1 -end - -unless defined?(FCGI) - puts "PROBLEM: Lighttpd requires that the FCGI Ruby bindings are installed on the system" - exit 1 -end - -require 'initializer' -configuration = Rails::Initializer.run(:initialize_logger).configuration -default_config_file = config_file = Pathname.new("#{RAILS_ROOT}/config/lighttpd.conf").cleanpath - -require 'optparse' - -detach = false -command_line_port = nil - -ARGV.options do |opt| - opt.on("-p", "--port=port", "Changes the server.port number in the config/lighttpd.conf") { |port| command_line_port = port } - opt.on('-c', "--config=#{config_file}", 'Specify a different lighttpd config file.') { |path| config_file = path } - opt.on('-h', '--help', 'Show this message.') { puts opt; exit 0 } - opt.on('-d', '-d', 'Call with -d to detach') { detach = true; puts "=> Configuration in config/lighttpd.conf" } - opt.parse! -end - -unless File.exist?(config_file) - if config_file != default_config_file - puts "=> #{config_file} not found." - exit 1 - end - - require 'fileutils' - - source = File.expand_path(File.join(File.dirname(__FILE__), - "..", "..", "..", "configs", "lighttpd.conf")) - puts "=> #{config_file} not found, copying from #{source}" - - FileUtils.cp(source, config_file) -end - -# open the config/lighttpd.conf file and add the current user defined port setting to it -if command_line_port - File.open(config_file, 'r+') do |config| - lines = config.readlines - - lines.each do |line| - line.gsub!(/^\s*server.port\s*=\s*(\d+)/, "server.port = #{command_line_port}") - end - - config.rewind - config.print(lines) - config.truncate(config.pos) - end -end - -config = IO.read(config_file) -default_port, default_ip = 3000, '0.0.0.0' -port = config.scan(/^\s*server.port\s*=\s*(\d+)/).first rescue default_port -ip = config.scan(/^\s*server.bind\s*=\s*"([^"]+)"/).first rescue default_ip -puts "=> Rails #{Rails.version} application starting on http://#{ip || default_ip}:#{port || default_port}" - -tail_thread = nil - -if !detach - puts "=> Call with -d to detach" - puts "=> Ctrl-C to shutdown server (see config/lighttpd.conf for options)" - detach = false - tail_thread = tail(configuration.log_path) -end - -trap(:INT) { exit } - -begin - `rake tmp:sockets:clear` # Needed if lighttpd crashes or otherwise leaves FCGI sockets around - `lighttpd #{!detach ? "-D " : ""}-f #{config_file}` -ensure - unless detach - tail_thread.kill if tail_thread - puts 'Exiting' - - # Ensure FCGI processes are reaped - silence_stream(STDOUT) do - ARGV.replace ['-a', 'kill'] - require 'commands/process/reaper' - end - - `rake tmp:sockets:clear` # Remove sockets on clean shutdown - end -end diff --git a/railties/lib/commands/servers/mongrel.rb b/railties/lib/commands/servers/mongrel.rb deleted file mode 100644 index 7bb110f63a..0000000000 --- a/railties/lib/commands/servers/mongrel.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'rbconfig' -require 'commands/servers/base' - -unless defined?(Mongrel) - puts "PROBLEM: Mongrel is not available on your system (or not in your path)" - exit 1 -end - -require 'optparse' - -OPTIONS = { - :port => 3000, - :ip => "0.0.0.0", - :environment => (ENV['RAILS_ENV'] || "development").dup, - :detach => false, - :debugger => false -} - -ARGV.clone.options do |opts| - opts.on("-p", "--port=port", Integer, "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: 0.0.0.0") { |v| OPTIONS[:ip] = v } - opts.on("-d", "--daemon", "Make server run as a Daemon.") { OPTIONS[:detach] = 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: development") { |v| OPTIONS[:environment] = v } - - opts.separator "" - - opts.on("-h", "--help", "Show this help message.") { puts opts; exit } - - opts.parse! -end - -puts "=> Rails #{Rails.version} application starting on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}" - -parameters = [ - "start", - "-p", OPTIONS[:port].to_s, - "-a", OPTIONS[:ip].to_s, - "-e", OPTIONS[:environment], - "-P", "#{RAILS_ROOT}/tmp/pids/mongrel.pid" -] - -if OPTIONS[:detach] - `mongrel_rails #{parameters.join(" ")} -d` -else - ENV["RAILS_ENV"] = OPTIONS[:environment] - RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV) - - start_debugger if OPTIONS[:debugger] - - puts "=> Call with -d to detach" - puts "=> Ctrl-C to shutdown server" - - log = Pathname.new("#{File.expand_path(RAILS_ROOT)}/log/#{RAILS_ENV}.log").cleanpath - open(log, (File::WRONLY | File::APPEND | File::CREAT)) unless File.exist? log - tail_thread = tail(log) - - trap(:INT) { exit } - - begin - silence_warnings { ARGV = parameters } - load("mongrel_rails") - ensure - tail_thread.kill if tail_thread - puts 'Exiting' - end -end
\ No newline at end of file diff --git a/railties/lib/commands/servers/new_mongrel.rb b/railties/lib/commands/servers/new_mongrel.rb deleted file mode 100644 index 174dbf8a37..0000000000 --- a/railties/lib/commands/servers/new_mongrel.rb +++ /dev/null @@ -1,16 +0,0 @@ -unless defined?(Mongrel) - abort "PROBLEM: Mongrel is not available on your system (or not in your path)" -end - -require 'rails/mongrel_server/commands' - -GemPlugin::Manager.instance.load "rails::mongrel" => GemPlugin::INCLUDE, "rails" => GemPlugin::EXCLUDE - -case ARGV[0] ||= 'start' -when 'start', 'stop', 'restart' - ARGV[0] = "rails::mongrelserver::#{ARGV[0]}" -end - -if not Mongrel::Command::Registry.instance.run ARGV - exit 1 -end diff --git a/railties/lib/commands/servers/thin.rb b/railties/lib/commands/servers/thin.rb deleted file mode 100644 index 833469cab1..0000000000 --- a/railties/lib/commands/servers/thin.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'rbconfig' -require 'commands/servers/base' -require 'thin' - - -options = ARGV.clone -options.insert(0,'start') unless Thin::Runner.commands.include?(options[0]) - -thin = Thin::Runner.new(options) - -puts "=> Rails #{Rails.version} application starting on http://#{thin.options[:address]}:#{thin.options[:port]}" -puts "=> Ctrl-C to shutdown server" - -log = Pathname.new("#{File.expand_path(RAILS_ROOT)}/log/#{RAILS_ENV}.log").cleanpath -open(log, (File::WRONLY | File::APPEND | File::CREAT)) unless File.exist? log -tail_thread = tail(log) -trap(:INT) { exit } - -begin - thin.run! -ensure - tail_thread.kill if tail_thread - puts 'Exiting' -end - diff --git a/railties/lib/commands/servers/webrick.rb b/railties/lib/commands/servers/webrick.rb deleted file mode 100644 index 18c8897cc8..0000000000 --- a/railties/lib/commands/servers/webrick.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'webrick' -require 'optparse' -require 'commands/servers/base' - -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, - :debugger => false - -} - -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") { |v| OPTIONS[:port] = v } - opts.on("-b", "--binding=ip", String, - "Binds Rails to the specified ip.", - "Default: 0.0.0.0") { |v| OPTIONS[:ip] = v } - opts.on("-e", "--environment=name", String, - "Specifies the environment to run this server under (test/development/production).", - "Default: development") { |v| OPTIONS[:environment] = v } - 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("-u", "--debugger", "Enable ruby-debugging for the server.") { OPTIONS[:debugger] = true } - - opts.on("-c", "--charset=charset", String, - "Set default charset for output.", - "Default: UTF-8") { |v| OPTIONS[:charset] = v } - - opts.separator "" - - opts.on("-h", "--help", - "Show this help message.") { puts opts; exit } - - opts.parse! -end - -start_debugger if OPTIONS[:debugger] - -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 #{Rails.version} 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) |