thin 1.2.3-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of thin might be problematic. Click here for more details.
- data/CHANGELOG +263 -0
- data/COPYING +18 -0
- data/README +69 -0
- data/Rakefile +36 -0
- data/benchmark/abc +51 -0
- data/benchmark/benchmarker.rb +80 -0
- data/benchmark/runner +82 -0
- data/bin/thin +6 -0
- data/example/adapter.rb +32 -0
- data/example/async_app.ru +126 -0
- data/example/async_chat.ru +247 -0
- data/example/async_tailer.ru +100 -0
- data/example/config.ru +22 -0
- data/example/monit_sockets +20 -0
- data/example/monit_unixsock +20 -0
- data/example/myapp.rb +1 -0
- data/example/ramaze.ru +12 -0
- data/example/thin.god +80 -0
- data/example/thin_solaris_smf.erb +36 -0
- data/example/thin_solaris_smf.readme.txt +150 -0
- data/example/vlad.rake +64 -0
- data/ext/thin_parser/common.rl +55 -0
- data/ext/thin_parser/ext_help.h +14 -0
- data/ext/thin_parser/extconf.rb +6 -0
- data/ext/thin_parser/parser.c +452 -0
- data/ext/thin_parser/parser.h +49 -0
- data/ext/thin_parser/parser.rl +157 -0
- data/ext/thin_parser/thin.c +433 -0
- data/lib/rack/adapter/loader.rb +79 -0
- data/lib/rack/adapter/rails.rb +181 -0
- data/lib/thin.rb +46 -0
- data/lib/thin/backends/base.rb +141 -0
- data/lib/thin/backends/swiftiply_client.rb +56 -0
- data/lib/thin/backends/tcp_server.rb +29 -0
- data/lib/thin/backends/unix_server.rb +51 -0
- data/lib/thin/command.rb +53 -0
- data/lib/thin/connection.rb +222 -0
- data/lib/thin/controllers/cluster.rb +127 -0
- data/lib/thin/controllers/controller.rb +183 -0
- data/lib/thin/controllers/service.rb +75 -0
- data/lib/thin/controllers/service.sh.erb +39 -0
- data/lib/thin/daemonizing.rb +174 -0
- data/lib/thin/headers.rb +39 -0
- data/lib/thin/logging.rb +54 -0
- data/lib/thin/request.rb +153 -0
- data/lib/thin/response.rb +101 -0
- data/lib/thin/runner.rb +209 -0
- data/lib/thin/server.rb +247 -0
- data/lib/thin/stats.html.erb +216 -0
- data/lib/thin/stats.rb +52 -0
- data/lib/thin/statuses.rb +43 -0
- data/lib/thin/version.rb +32 -0
- data/lib/thin_parser.so +0 -0
- data/spec/backends/swiftiply_client_spec.rb +66 -0
- data/spec/backends/tcp_server_spec.rb +33 -0
- data/spec/backends/unix_server_spec.rb +37 -0
- data/spec/command_spec.rb +25 -0
- data/spec/configs/cluster.yml +9 -0
- data/spec/configs/single.yml +9 -0
- data/spec/connection_spec.rb +106 -0
- data/spec/controllers/cluster_spec.rb +235 -0
- data/spec/controllers/controller_spec.rb +129 -0
- data/spec/controllers/service_spec.rb +50 -0
- data/spec/daemonizing_spec.rb +192 -0
- data/spec/headers_spec.rb +40 -0
- data/spec/logging_spec.rb +46 -0
- data/spec/perf/request_perf_spec.rb +50 -0
- data/spec/perf/response_perf_spec.rb +19 -0
- data/spec/perf/server_perf_spec.rb +39 -0
- data/spec/rack/loader_spec.rb +29 -0
- data/spec/rack/rails_adapter_spec.rb +106 -0
- data/spec/rails_app/app/controllers/application.rb +10 -0
- data/spec/rails_app/app/controllers/simple_controller.rb +19 -0
- data/spec/rails_app/app/helpers/application_helper.rb +3 -0
- data/spec/rails_app/app/views/simple/index.html.erb +15 -0
- data/spec/rails_app/config/boot.rb +109 -0
- data/spec/rails_app/config/environment.rb +64 -0
- data/spec/rails_app/config/environments/development.rb +18 -0
- data/spec/rails_app/config/environments/production.rb +19 -0
- data/spec/rails_app/config/environments/test.rb +22 -0
- data/spec/rails_app/config/initializers/inflections.rb +10 -0
- data/spec/rails_app/config/initializers/mime_types.rb +5 -0
- data/spec/rails_app/config/routes.rb +35 -0
- data/spec/rails_app/public/404.html +30 -0
- data/spec/rails_app/public/422.html +30 -0
- data/spec/rails_app/public/500.html +30 -0
- data/spec/rails_app/public/dispatch.cgi +10 -0
- data/spec/rails_app/public/dispatch.fcgi +24 -0
- data/spec/rails_app/public/dispatch.rb +10 -0
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/images/rails.png +0 -0
- data/spec/rails_app/public/index.html +277 -0
- data/spec/rails_app/public/javascripts/application.js +2 -0
- data/spec/rails_app/public/javascripts/controls.js +963 -0
- data/spec/rails_app/public/javascripts/dragdrop.js +972 -0
- data/spec/rails_app/public/javascripts/effects.js +1120 -0
- data/spec/rails_app/public/javascripts/prototype.js +4225 -0
- data/spec/rails_app/public/robots.txt +5 -0
- data/spec/rails_app/script/about +3 -0
- data/spec/rails_app/script/console +3 -0
- data/spec/rails_app/script/destroy +3 -0
- data/spec/rails_app/script/generate +3 -0
- data/spec/rails_app/script/performance/benchmarker +3 -0
- data/spec/rails_app/script/performance/profiler +3 -0
- data/spec/rails_app/script/performance/request +3 -0
- data/spec/rails_app/script/plugin +3 -0
- data/spec/rails_app/script/process/inspector +3 -0
- data/spec/rails_app/script/process/reaper +3 -0
- data/spec/rails_app/script/process/spawner +3 -0
- data/spec/rails_app/script/runner +3 -0
- data/spec/rails_app/script/server +3 -0
- data/spec/request/mongrel_spec.rb +39 -0
- data/spec/request/parser_spec.rb +215 -0
- data/spec/request/persistent_spec.rb +35 -0
- data/spec/request/processing_spec.rb +45 -0
- data/spec/response_spec.rb +91 -0
- data/spec/runner_spec.rb +168 -0
- data/spec/server/builder_spec.rb +44 -0
- data/spec/server/pipelining_spec.rb +110 -0
- data/spec/server/robustness_spec.rb +34 -0
- data/spec/server/stopping_spec.rb +55 -0
- data/spec/server/swiftiply.yml +6 -0
- data/spec/server/swiftiply_spec.rb +32 -0
- data/spec/server/tcp_spec.rb +57 -0
- data/spec/server/threaded_spec.rb +27 -0
- data/spec/server/unix_socket_spec.rb +26 -0
- data/spec/server_spec.rb +96 -0
- data/spec/spec_helper.rb +219 -0
- data/tasks/announce.rake +22 -0
- data/tasks/deploy.rake +13 -0
- data/tasks/email.erb +30 -0
- data/tasks/gem.rake +74 -0
- data/tasks/rdoc.rake +25 -0
- data/tasks/site.rake +15 -0
- data/tasks/spec.rake +49 -0
- data/tasks/stats.rake +28 -0
- metadata +246 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Request, 'performance' do
|
4
|
+
it "should be faster then #{max_parsing_time = 0.0002} RubySeconds" do
|
5
|
+
body = <<-EOS.chomp.gsub("\n", "\r\n")
|
6
|
+
POST /postit HTTP/1.1
|
7
|
+
Host: localhost:3000
|
8
|
+
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9
|
9
|
+
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
|
10
|
+
Accept-Language: en-us,en;q=0.5
|
11
|
+
Accept-Encoding: gzip,deflate
|
12
|
+
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
|
13
|
+
Keep-Alive: 300
|
14
|
+
Connection: keep-alive
|
15
|
+
Content-Type: text/html
|
16
|
+
Content-Length: 37
|
17
|
+
|
18
|
+
hi=there&name=marc&email=macournoyer@gmail.com
|
19
|
+
EOS
|
20
|
+
|
21
|
+
proc { R(body) }.should be_faster_then(max_parsing_time)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should be comparable to Mongrel parser' do
|
25
|
+
require 'http11'
|
26
|
+
|
27
|
+
body = <<-EOS.chomp.gsub("\n", "\r\n")
|
28
|
+
POST /postit HTTP/1.1
|
29
|
+
Host: localhost:3000
|
30
|
+
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9
|
31
|
+
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
|
32
|
+
Accept-Language: en-us,en;q=0.5
|
33
|
+
Accept-Encoding: gzip,deflate
|
34
|
+
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
|
35
|
+
Keep-Alive: 300
|
36
|
+
Connection: keep-alive
|
37
|
+
Content-Type: text/html
|
38
|
+
Content-Length: 37
|
39
|
+
|
40
|
+
hi=there&name=marc&email=macournoyer@gmail.com
|
41
|
+
EOS
|
42
|
+
|
43
|
+
tests = 10_000
|
44
|
+
puts
|
45
|
+
Benchmark.bmbm(10) do |results|
|
46
|
+
results.report("mongrel:") { tests.times { Mongrel::HttpParser.new.execute({}, body.dup, 0) } }
|
47
|
+
results.report("thin:") { tests.times { Thin::HttpParser.new.execute({'rack.input' => StringIO.new}, body.dup, 0) } }
|
48
|
+
end
|
49
|
+
end if ENV['BM']
|
50
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Response, 'performance' do
|
4
|
+
before do
|
5
|
+
@response = Response.new
|
6
|
+
@response.body = ''
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be fast" do
|
10
|
+
@response.body << <<-EOS
|
11
|
+
<html><head><title>Dir listing</title></head>
|
12
|
+
<body><h1>Listing stuff</h1><ul>
|
13
|
+
#{'<li>Hi!</li>' * 100}
|
14
|
+
</ul></body></html>
|
15
|
+
EOS
|
16
|
+
|
17
|
+
proc { @response.each { |l| l } }.should be_faster_then(0.00011)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Server, 'performance' do
|
4
|
+
before do
|
5
|
+
start_server do |env|
|
6
|
+
body = env.inspect + env['rack.input'].read
|
7
|
+
[200, { 'Content-Length' => body.size.to_s }, body]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should handle GET in less then #{get_request_time = 0.0045} RubySecond" do
|
12
|
+
proc { get('/') }.should be_faster_then(get_request_time)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should handle POST in less then #{post_request_time = 0.007} RubySecond" do
|
16
|
+
proc { post('/', :file => 'X' * 1000) }.should be_faster_then(post_request_time)
|
17
|
+
end
|
18
|
+
|
19
|
+
after do
|
20
|
+
stop_server
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe Server, 'UNIX socket performance' do
|
25
|
+
before do
|
26
|
+
start_server('/tmp/thin_test.sock') do |env|
|
27
|
+
body = env.inspect + env['rack.input'].read
|
28
|
+
[200, { 'Content-Length' => body.size.to_s }, body]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should handle GET in less then #{get_request_time = 0.002} RubySecond" do
|
33
|
+
proc { get('/') }.should be_faster_then(get_request_time)
|
34
|
+
end
|
35
|
+
|
36
|
+
after do
|
37
|
+
stop_server
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Rack::Adapter do
|
4
|
+
before do
|
5
|
+
@rails_path = File.dirname(__FILE__) + '/../rails_app'
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should guess rails app from dir" do
|
9
|
+
Rack::Adapter.guess(@rails_path).should == :rails
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return nil when can't guess from dir" do
|
13
|
+
proc { Rack::Adapter.guess('.') }.should raise_error(Rack::AdapterNotFound)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should load Rails adapter" do
|
17
|
+
Rack::Adapter::Rails.should_receive(:new)
|
18
|
+
Rack::Adapter.for(:rails, :chdir => @rails_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should load File adapter" do
|
22
|
+
Rack::File.should_receive(:new)
|
23
|
+
Rack::Adapter.for(:file)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should raise error when adapter can't be found" do
|
27
|
+
proc { Rack::Adapter.for(:fart, {}) }.should raise_error(Rack::AdapterNotFound)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'rack/mock'
|
3
|
+
|
4
|
+
begin
|
5
|
+
gem 'rails', '= 2.0.2' # We could freeze Rails in the rails_app dir to remove this
|
6
|
+
|
7
|
+
describe Rack::Adapter::Rails do
|
8
|
+
before do
|
9
|
+
@rails_app_path = File.dirname(__FILE__) + '/../rails_app'
|
10
|
+
@request = Rack::MockRequest.new(Rack::Adapter::Rails.new(:root => @rails_app_path))
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should handle simple GET request" do
|
14
|
+
res = @request.get("/simple", :lint => true)
|
15
|
+
|
16
|
+
res.should be_ok
|
17
|
+
res["Content-Type"].should include("text/html")
|
18
|
+
|
19
|
+
res.body.should include('Simple#index')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should handle POST parameters" do
|
23
|
+
data = "foo=bar"
|
24
|
+
res = @request.post("/simple/post_form", :input => data, 'CONTENT_LENGTH' => data.size.to_s, :lint => true)
|
25
|
+
|
26
|
+
res.should be_ok
|
27
|
+
res["Content-Type"].should include("text/html")
|
28
|
+
res["Content-Length"].should_not be_nil
|
29
|
+
|
30
|
+
res.body.should include('foo: bar')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should serve static files" do
|
34
|
+
res = @request.get("/index.html", :lint => true)
|
35
|
+
|
36
|
+
res.should be_ok
|
37
|
+
res["Content-Type"].should include("text/html")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should serve root with index.html if present" do
|
41
|
+
res = @request.get("/", :lint => true)
|
42
|
+
|
43
|
+
res.should be_ok
|
44
|
+
res["Content-Length"].to_i.should == File.size(@rails_app_path + '/public/index.html')
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should serve page cache if present" do
|
48
|
+
res = @request.get("/simple/cached?value=cached", :lint => true)
|
49
|
+
|
50
|
+
res.should be_ok
|
51
|
+
res.body.should == 'cached'
|
52
|
+
|
53
|
+
res = @request.get("/simple/cached?value=notcached")
|
54
|
+
|
55
|
+
res.should be_ok
|
56
|
+
res.body.should == 'cached'
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not serve page cache on POST request" do
|
60
|
+
res = @request.get("/simple/cached?value=cached", :lint => true)
|
61
|
+
|
62
|
+
res.should be_ok
|
63
|
+
res.body.should == 'cached'
|
64
|
+
|
65
|
+
res = @request.post("/simple/cached?value=notcached")
|
66
|
+
|
67
|
+
res.should be_ok
|
68
|
+
res.body.should == 'notcached'
|
69
|
+
end
|
70
|
+
|
71
|
+
it "handles multiple cookies" do
|
72
|
+
res = @request.get('/simple/set_cookie?name=a&value=1', :lint => true)
|
73
|
+
|
74
|
+
res.should be_ok
|
75
|
+
res.original_headers['Set-Cookie'].size.should == 2
|
76
|
+
res.original_headers['Set-Cookie'].first.should include('a=1; path=/')
|
77
|
+
res.original_headers['Set-Cookie'].last.should include('_rails_app_session')
|
78
|
+
end
|
79
|
+
|
80
|
+
after do
|
81
|
+
FileUtils.rm_rf @rails_app_path + '/public/simple'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe Rack::Adapter::Rails, 'with prefix' do
|
86
|
+
before do
|
87
|
+
@rails_app_path = File.dirname(__FILE__) + '/../rails_app'
|
88
|
+
@prefix = '/nowhere'
|
89
|
+
@request = Rack::MockRequest.new(
|
90
|
+
Rack::URLMap.new(
|
91
|
+
@prefix => Rack::Adapter::Rails.new(:root => @rails_app_path, :prefix => @prefix)))
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should handle simple GET request" do
|
95
|
+
res = @request.get("#{@prefix}/simple", :lint => true)
|
96
|
+
|
97
|
+
res.should be_ok
|
98
|
+
res["Content-Type"].should include("text/html")
|
99
|
+
|
100
|
+
res.body.should include('Simple#index')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
rescue Gem::LoadError
|
105
|
+
warn 'Rails 2.0.2 is required to run the Rails adapter specs'
|
106
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
helper :all # include all helpers, all the time
|
6
|
+
|
7
|
+
# See ActionController::RequestForgeryProtection for details
|
8
|
+
# Uncomment the :secret if you're not using the cookie session store
|
9
|
+
# protect_from_forgery # :secret => 'a8af303b8dabf2d2d8f1a7912ac04d7d'
|
10
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class SimpleController < ApplicationController
|
2
|
+
caches_page :cached
|
3
|
+
|
4
|
+
def index
|
5
|
+
end
|
6
|
+
|
7
|
+
def post_form
|
8
|
+
render :text => params.to_yaml
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_cookie
|
12
|
+
cookies[params[:name]] = params[:value] if params[:name]
|
13
|
+
render :text => cookies.to_yaml
|
14
|
+
end
|
15
|
+
|
16
|
+
def cached
|
17
|
+
render :text => params[:value]
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<h1>Simple#index</h1>
|
2
|
+
|
3
|
+
<h2>ENV</h2>
|
4
|
+
<%= request.env.to_yaml %>
|
5
|
+
|
6
|
+
<h2>Cookies</h2>
|
7
|
+
<%= request.cookies.to_yaml %>
|
8
|
+
|
9
|
+
<h2>Params</h2>
|
10
|
+
<%= params.to_yaml %>
|
11
|
+
|
12
|
+
<% form_tag '/simple' do %>
|
13
|
+
<%= text_field_tag :a %>
|
14
|
+
<%= submit_tag 'Submit' %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# Don't change this file!
|
2
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
+
|
4
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class << self
|
8
|
+
def boot!
|
9
|
+
unless booted?
|
10
|
+
preinitialize
|
11
|
+
pick_boot.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def booted?
|
16
|
+
defined? Rails::Initializer
|
17
|
+
end
|
18
|
+
|
19
|
+
def pick_boot
|
20
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor_rails?
|
24
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
+
end
|
26
|
+
|
27
|
+
# FIXME : Ruby 1.9
|
28
|
+
def preinitialize
|
29
|
+
load(preinitializer_path) if File.exists?(preinitializer_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def preinitializer_path
|
33
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Boot
|
38
|
+
def run
|
39
|
+
load_initializer
|
40
|
+
Rails::Initializer.run(:set_load_path)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class VendorBoot < Boot
|
45
|
+
def load_initializer
|
46
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class GemBoot < Boot
|
51
|
+
def load_initializer
|
52
|
+
self.class.load_rubygems
|
53
|
+
load_rails_gem
|
54
|
+
require 'initializer'
|
55
|
+
end
|
56
|
+
|
57
|
+
def load_rails_gem
|
58
|
+
if version = self.class.gem_version
|
59
|
+
gem 'rails', version
|
60
|
+
else
|
61
|
+
gem 'rails'
|
62
|
+
end
|
63
|
+
rescue Gem::LoadError => load_error
|
64
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
class << self
|
69
|
+
def rubygems_version
|
70
|
+
Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
|
71
|
+
end
|
72
|
+
|
73
|
+
def gem_version
|
74
|
+
if defined? RAILS_GEM_VERSION
|
75
|
+
RAILS_GEM_VERSION
|
76
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
77
|
+
ENV['RAILS_GEM_VERSION']
|
78
|
+
else
|
79
|
+
parse_gem_version(read_environment_rb)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_rubygems
|
84
|
+
require 'rubygems'
|
85
|
+
|
86
|
+
unless rubygems_version >= '0.9.4'
|
87
|
+
$stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
88
|
+
exit 1
|
89
|
+
end
|
90
|
+
|
91
|
+
rescue LoadError
|
92
|
+
$stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
93
|
+
exit 1
|
94
|
+
end
|
95
|
+
|
96
|
+
def parse_gem_version(text)
|
97
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
def read_environment_rb
|
102
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# All that for this:
|
109
|
+
Rails.boot!
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file
|
2
|
+
|
3
|
+
# Uncomment below to force Rails into production mode when
|
4
|
+
# you don't control web/app server and can't set it the proper way
|
5
|
+
# ENV['RAILS_ENV'] ||= 'production'
|
6
|
+
|
7
|
+
# Specifies gem version of Rails to use when vendor/rails is not present
|
8
|
+
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
|
9
|
+
|
10
|
+
# Bootstrap the Rails environment, frameworks, and default configuration
|
11
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
12
|
+
|
13
|
+
Rails::Initializer.run do |config|
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
# See Rails::Configuration for more options.
|
18
|
+
|
19
|
+
# Skip frameworks you're not going to use (only works if using vendor/rails).
|
20
|
+
# To use Rails without a database, you must remove the Active Record framework
|
21
|
+
config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
|
22
|
+
|
23
|
+
# Only load the plugins named here, in the order given. By default, all plugins
|
24
|
+
# in vendor/plugins are loaded in alphabetical order.
|
25
|
+
# :all can be used as a placeholder for all plugins not explicitly named
|
26
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
27
|
+
|
28
|
+
# Add additional load paths for your own custom dirs
|
29
|
+
# config.load_paths += %W( #{RAILS_ROOT}/extras )
|
30
|
+
|
31
|
+
# No need for log files
|
32
|
+
config.logger = Logger.new(nil)
|
33
|
+
|
34
|
+
# Force all environments to use the same logger level
|
35
|
+
# (by default production uses :info, the others :debug)
|
36
|
+
# config.log_level = :debug
|
37
|
+
|
38
|
+
# Your secret key for verifying cookie session data integrity.
|
39
|
+
# If you change this key, all old sessions will become invalid!
|
40
|
+
# Make sure the secret is at least 30 characters and all random,
|
41
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
42
|
+
config.action_controller.session = {
|
43
|
+
:session_key => '_rails_app_session',
|
44
|
+
:secret => 'cb7141365b4443eff37e7122473e704ceae95146a4028930b21300965fe6abec51e3e93b2670a914b3b65d06058b81aadfe6b240d63e7d7713db044b42a6e1c1'
|
45
|
+
}
|
46
|
+
|
47
|
+
config.action_controller.allow_forgery_protection = false
|
48
|
+
|
49
|
+
# Use the database for sessions instead of the cookie-based default,
|
50
|
+
# which shouldn't be used to store highly confidential information
|
51
|
+
# (create the session table with 'rake db:sessions:create')
|
52
|
+
# config.action_controller.session_store = :active_record_store
|
53
|
+
|
54
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
55
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
56
|
+
# like if you have constraints or database-specific column types
|
57
|
+
# config.active_record.schema_format = :sql
|
58
|
+
|
59
|
+
# Activate observers that should always be running
|
60
|
+
# config.active_record.observers = :cacher, :garbage_collector
|
61
|
+
|
62
|
+
# Make Active Record use UTC-base instead of local time
|
63
|
+
# config.active_record.default_timezone = :utc
|
64
|
+
end
|