giraffesoft-unicorn 0.93.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.CHANGELOG.old +25 -0
- data/.document +16 -0
- data/.gitignore +20 -0
- data/.mailmap +26 -0
- data/CONTRIBUTORS +31 -0
- data/COPYING +339 -0
- data/DESIGN +105 -0
- data/Documentation/.gitignore +5 -0
- data/Documentation/GNUmakefile +30 -0
- data/Documentation/unicorn.1.txt +167 -0
- data/Documentation/unicorn_rails.1.txt +169 -0
- data/GIT-VERSION-GEN +40 -0
- data/GNUmakefile +270 -0
- data/HACKING +113 -0
- data/KNOWN_ISSUES +40 -0
- data/LICENSE +55 -0
- data/PHILOSOPHY +144 -0
- data/README +153 -0
- data/Rakefile +108 -0
- data/SIGNALS +97 -0
- data/TODO +16 -0
- data/TUNING +70 -0
- data/bin/unicorn +165 -0
- data/bin/unicorn_rails +208 -0
- data/examples/echo.ru +27 -0
- data/examples/git.ru +13 -0
- data/examples/init.sh +53 -0
- data/ext/unicorn_http/c_util.h +107 -0
- data/ext/unicorn_http/common_field_optimization.h +111 -0
- data/ext/unicorn_http/ext_help.h +73 -0
- data/ext/unicorn_http/extconf.rb +14 -0
- data/ext/unicorn_http/global_variables.h +91 -0
- data/ext/unicorn_http/unicorn_http.rl +715 -0
- data/ext/unicorn_http/unicorn_http_common.rl +74 -0
- data/lib/unicorn.rb +730 -0
- data/lib/unicorn/app/exec_cgi.rb +150 -0
- data/lib/unicorn/app/inetd.rb +109 -0
- data/lib/unicorn/app/old_rails.rb +31 -0
- data/lib/unicorn/app/old_rails/static.rb +60 -0
- data/lib/unicorn/cgi_wrapper.rb +145 -0
- data/lib/unicorn/configurator.rb +403 -0
- data/lib/unicorn/const.rb +37 -0
- data/lib/unicorn/http_request.rb +74 -0
- data/lib/unicorn/http_response.rb +74 -0
- data/lib/unicorn/launcher.rb +39 -0
- data/lib/unicorn/socket_helper.rb +138 -0
- data/lib/unicorn/tee_input.rb +174 -0
- data/lib/unicorn/util.rb +64 -0
- data/local.mk.sample +53 -0
- data/setup.rb +1586 -0
- data/test/aggregate.rb +15 -0
- data/test/benchmark/README +50 -0
- data/test/benchmark/dd.ru +18 -0
- data/test/exec/README +5 -0
- data/test/exec/test_exec.rb +855 -0
- data/test/rails/app-1.2.3/.gitignore +2 -0
- data/test/rails/app-1.2.3/Rakefile +7 -0
- data/test/rails/app-1.2.3/app/controllers/application.rb +6 -0
- data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-1.2.3/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-1.2.3/config/boot.rb +11 -0
- data/test/rails/app-1.2.3/config/database.yml +12 -0
- data/test/rails/app-1.2.3/config/environment.rb +13 -0
- data/test/rails/app-1.2.3/config/environments/development.rb +9 -0
- data/test/rails/app-1.2.3/config/environments/production.rb +5 -0
- data/test/rails/app-1.2.3/config/routes.rb +6 -0
- data/test/rails/app-1.2.3/db/.gitignore +0 -0
- data/test/rails/app-1.2.3/public/404.html +1 -0
- data/test/rails/app-1.2.3/public/500.html +1 -0
- data/test/rails/app-2.0.2/.gitignore +2 -0
- data/test/rails/app-2.0.2/Rakefile +7 -0
- data/test/rails/app-2.0.2/app/controllers/application.rb +4 -0
- data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-2.0.2/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-2.0.2/config/boot.rb +11 -0
- data/test/rails/app-2.0.2/config/database.yml +12 -0
- data/test/rails/app-2.0.2/config/environment.rb +17 -0
- data/test/rails/app-2.0.2/config/environments/development.rb +8 -0
- data/test/rails/app-2.0.2/config/environments/production.rb +5 -0
- data/test/rails/app-2.0.2/config/routes.rb +6 -0
- data/test/rails/app-2.0.2/db/.gitignore +0 -0
- data/test/rails/app-2.0.2/public/404.html +1 -0
- data/test/rails/app-2.0.2/public/500.html +1 -0
- data/test/rails/app-2.1.2/.gitignore +2 -0
- data/test/rails/app-2.1.2/Rakefile +7 -0
- data/test/rails/app-2.1.2/app/controllers/application.rb +4 -0
- data/test/rails/app-2.1.2/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-2.1.2/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-2.1.2/config/boot.rb +111 -0
- data/test/rails/app-2.1.2/config/database.yml +12 -0
- data/test/rails/app-2.1.2/config/environment.rb +17 -0
- data/test/rails/app-2.1.2/config/environments/development.rb +7 -0
- data/test/rails/app-2.1.2/config/environments/production.rb +5 -0
- data/test/rails/app-2.1.2/config/routes.rb +6 -0
- data/test/rails/app-2.1.2/db/.gitignore +0 -0
- data/test/rails/app-2.1.2/public/404.html +1 -0
- data/test/rails/app-2.1.2/public/500.html +1 -0
- data/test/rails/app-2.2.2/.gitignore +2 -0
- data/test/rails/app-2.2.2/Rakefile +7 -0
- data/test/rails/app-2.2.2/app/controllers/application.rb +4 -0
- data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-2.2.2/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-2.2.2/config/boot.rb +111 -0
- data/test/rails/app-2.2.2/config/database.yml +12 -0
- data/test/rails/app-2.2.2/config/environment.rb +17 -0
- data/test/rails/app-2.2.2/config/environments/development.rb +7 -0
- data/test/rails/app-2.2.2/config/environments/production.rb +5 -0
- data/test/rails/app-2.2.2/config/routes.rb +6 -0
- data/test/rails/app-2.2.2/db/.gitignore +0 -0
- data/test/rails/app-2.2.2/public/404.html +1 -0
- data/test/rails/app-2.2.2/public/500.html +1 -0
- data/test/rails/app-2.3.3.1/.gitignore +2 -0
- data/test/rails/app-2.3.3.1/Rakefile +7 -0
- data/test/rails/app-2.3.3.1/app/controllers/application_controller.rb +5 -0
- data/test/rails/app-2.3.3.1/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-2.3.3.1/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-2.3.3.1/config/boot.rb +109 -0
- data/test/rails/app-2.3.3.1/config/database.yml +12 -0
- data/test/rails/app-2.3.3.1/config/environment.rb +17 -0
- data/test/rails/app-2.3.3.1/config/environments/development.rb +7 -0
- data/test/rails/app-2.3.3.1/config/environments/production.rb +6 -0
- data/test/rails/app-2.3.3.1/config/routes.rb +6 -0
- data/test/rails/app-2.3.3.1/db/.gitignore +0 -0
- data/test/rails/app-2.3.3.1/public/404.html +1 -0
- data/test/rails/app-2.3.3.1/public/500.html +1 -0
- data/test/rails/app-2.3.3.1/public/x.txt +1 -0
- data/test/rails/test_rails.rb +280 -0
- data/test/test_helper.rb +296 -0
- data/test/unit/test_configurator.rb +150 -0
- data/test/unit/test_http_parser.rb +492 -0
- data/test/unit/test_http_parser_ng.rb +308 -0
- data/test/unit/test_request.rb +184 -0
- data/test/unit/test_response.rb +110 -0
- data/test/unit/test_server.rb +188 -0
- data/test/unit/test_signals.rb +202 -0
- data/test/unit/test_socket_helper.rb +133 -0
- data/test/unit/test_tee_input.rb +229 -0
- data/test/unit/test_upload.rb +297 -0
- data/test/unit/test_util.rb +96 -0
- data/unicorn.gemspec +42 -0
- metadata +228 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
2
|
+
|
3
|
+
unless defined? RAILS_GEM_VERSION
|
4
|
+
RAILS_GEM_VERSION = ENV['UNICORN_RAILS_VERSION']
|
5
|
+
end
|
6
|
+
|
7
|
+
# Bootstrap the Rails environment, frameworks, and default configuration
|
8
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
9
|
+
|
10
|
+
Rails::Initializer.run do |config|
|
11
|
+
config.frameworks -= [ :action_web_service, :action_mailer ]
|
12
|
+
config.action_controller.session_store = :active_record_store
|
13
|
+
config.action_controller.session = {
|
14
|
+
:session_key => "_unicorn_rails_test.#{rand}",
|
15
|
+
:secret => "#{rand}#{rand}#{rand}#{rand}",
|
16
|
+
}
|
17
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
404 Not Found
|
@@ -0,0 +1 @@
|
|
1
|
+
500 Internal Server Error
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
2
|
+
|
3
|
+
require 'digest/sha1'
|
4
|
+
class FooController < ApplicationController
|
5
|
+
def index
|
6
|
+
render :text => "FOO\n"
|
7
|
+
end
|
8
|
+
|
9
|
+
def xcookie
|
10
|
+
cookies["foo"] = "cookie #$$"
|
11
|
+
render :text => ""
|
12
|
+
end
|
13
|
+
|
14
|
+
def xnotice
|
15
|
+
flash[:notice] = "session #$$"
|
16
|
+
render :text => ""
|
17
|
+
end
|
18
|
+
|
19
|
+
def xpost
|
20
|
+
if request.post?
|
21
|
+
digest = Digest::SHA1.new
|
22
|
+
out = "params: #{params.inspect}\n"
|
23
|
+
if file = params[:file]
|
24
|
+
loop do
|
25
|
+
buf = file.read(4096) or break
|
26
|
+
digest.update(buf)
|
27
|
+
end
|
28
|
+
out << "sha1: #{digest.to_s}\n"
|
29
|
+
end
|
30
|
+
headers['content-type'] = 'text/plain'
|
31
|
+
render :text => out
|
32
|
+
else
|
33
|
+
render :status => 403, :text => "need post\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
2
|
+
|
3
|
+
# Don't change this file!
|
4
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
5
|
+
|
6
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
7
|
+
|
8
|
+
module Rails
|
9
|
+
class << self
|
10
|
+
def boot!
|
11
|
+
unless booted?
|
12
|
+
preinitialize
|
13
|
+
pick_boot.run
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def booted?
|
18
|
+
defined? Rails::Initializer
|
19
|
+
end
|
20
|
+
|
21
|
+
def pick_boot
|
22
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
23
|
+
end
|
24
|
+
|
25
|
+
def vendor_rails?
|
26
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
27
|
+
end
|
28
|
+
|
29
|
+
def preinitialize
|
30
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def preinitializer_path
|
34
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Boot
|
39
|
+
def run
|
40
|
+
load_initializer
|
41
|
+
Rails::Initializer.run(:set_load_path)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class VendorBoot < Boot
|
46
|
+
def load_initializer
|
47
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
48
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class GemBoot < Boot
|
53
|
+
def load_initializer
|
54
|
+
self.class.load_rubygems
|
55
|
+
load_rails_gem
|
56
|
+
require 'initializer'
|
57
|
+
end
|
58
|
+
|
59
|
+
def load_rails_gem
|
60
|
+
if version = self.class.gem_version
|
61
|
+
gem 'rails', version
|
62
|
+
else
|
63
|
+
gem 'rails'
|
64
|
+
end
|
65
|
+
rescue Gem::LoadError => load_error
|
66
|
+
$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.)
|
67
|
+
exit 1
|
68
|
+
end
|
69
|
+
|
70
|
+
class << self
|
71
|
+
def rubygems_version
|
72
|
+
Gem::RubyGemsVersion rescue nil
|
73
|
+
end
|
74
|
+
|
75
|
+
def gem_version
|
76
|
+
if defined? RAILS_GEM_VERSION
|
77
|
+
RAILS_GEM_VERSION
|
78
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
79
|
+
ENV['RAILS_GEM_VERSION']
|
80
|
+
else
|
81
|
+
parse_gem_version(read_environment_rb)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def load_rubygems
|
86
|
+
require 'rubygems'
|
87
|
+
min_version = '1.3.1'
|
88
|
+
unless rubygems_version >= min_version
|
89
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
90
|
+
exit 1
|
91
|
+
end
|
92
|
+
|
93
|
+
rescue LoadError
|
94
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
95
|
+
exit 1
|
96
|
+
end
|
97
|
+
|
98
|
+
def parse_gem_version(text)
|
99
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
def read_environment_rb
|
104
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# All that for this:
|
111
|
+
Rails.boot!
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
2
|
+
|
3
|
+
unless defined? RAILS_GEM_VERSION
|
4
|
+
RAILS_GEM_VERSION = ENV['UNICORN_RAILS_VERSION']
|
5
|
+
end
|
6
|
+
|
7
|
+
# Bootstrap the Rails environment, frameworks, and default configuration
|
8
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
9
|
+
|
10
|
+
Rails::Initializer.run do |config|
|
11
|
+
config.frameworks -= [ :action_web_service, :action_mailer ]
|
12
|
+
config.action_controller.session_store = :active_record_store
|
13
|
+
config.action_controller.session = {
|
14
|
+
:session_key => "_unicorn_rails_test.#{rand}",
|
15
|
+
:secret => "#{rand}#{rand}#{rand}#{rand}",
|
16
|
+
}
|
17
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
404 Not Found
|
@@ -0,0 +1 @@
|
|
1
|
+
500 Internal Server Error
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
2
|
+
|
3
|
+
require 'digest/sha1'
|
4
|
+
class FooController < ApplicationController
|
5
|
+
def index
|
6
|
+
render :text => "FOO\n"
|
7
|
+
end
|
8
|
+
|
9
|
+
def xcookie
|
10
|
+
cookies["foo"] = "cookie-#$$-#{session[:gotta_use_the_session_in_2_3]}"
|
11
|
+
render :text => ""
|
12
|
+
end
|
13
|
+
|
14
|
+
def xnotice
|
15
|
+
flash[:notice] = "session #$$"
|
16
|
+
render :text => ""
|
17
|
+
end
|
18
|
+
|
19
|
+
def xpost
|
20
|
+
if request.post?
|
21
|
+
digest = Digest::SHA1.new
|
22
|
+
out = "params: #{params.inspect}\n"
|
23
|
+
if file = params[:file]
|
24
|
+
loop do
|
25
|
+
buf = file.read(4096) or break
|
26
|
+
digest.update(buf)
|
27
|
+
end
|
28
|
+
out << "sha1: #{digest.to_s}\n"
|
29
|
+
end
|
30
|
+
headers['content-type'] = 'text/plain'
|
31
|
+
render :text => out
|
32
|
+
else
|
33
|
+
render :status => 403, :text => "need post\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
2
|
+
|
3
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
class << self
|
7
|
+
def boot!
|
8
|
+
unless booted?
|
9
|
+
preinitialize
|
10
|
+
pick_boot.run
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def booted?
|
15
|
+
defined? Rails::Initializer
|
16
|
+
end
|
17
|
+
|
18
|
+
def pick_boot
|
19
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
20
|
+
end
|
21
|
+
|
22
|
+
def vendor_rails?
|
23
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
24
|
+
end
|
25
|
+
|
26
|
+
def preinitialize
|
27
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def preinitializer_path
|
31
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Boot
|
36
|
+
def run
|
37
|
+
load_initializer
|
38
|
+
Rails::Initializer.run(:set_load_path)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class VendorBoot < Boot
|
43
|
+
def load_initializer
|
44
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
45
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
46
|
+
Rails::GemDependency.add_frozen_gem_path
|
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 rescue nil
|
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
|
+
min_version = '1.3.1'
|
86
|
+
unless rubygems_version >= min_version
|
87
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
88
|
+
exit 1
|
89
|
+
end
|
90
|
+
|
91
|
+
rescue LoadError
|
92
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. 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!
|