giraffesoft-unicorn 0.93.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/.CHANGELOG.old +25 -0
  2. data/.document +16 -0
  3. data/.gitignore +20 -0
  4. data/.mailmap +26 -0
  5. data/CONTRIBUTORS +31 -0
  6. data/COPYING +339 -0
  7. data/DESIGN +105 -0
  8. data/Documentation/.gitignore +5 -0
  9. data/Documentation/GNUmakefile +30 -0
  10. data/Documentation/unicorn.1.txt +167 -0
  11. data/Documentation/unicorn_rails.1.txt +169 -0
  12. data/GIT-VERSION-GEN +40 -0
  13. data/GNUmakefile +270 -0
  14. data/HACKING +113 -0
  15. data/KNOWN_ISSUES +40 -0
  16. data/LICENSE +55 -0
  17. data/PHILOSOPHY +144 -0
  18. data/README +153 -0
  19. data/Rakefile +108 -0
  20. data/SIGNALS +97 -0
  21. data/TODO +16 -0
  22. data/TUNING +70 -0
  23. data/bin/unicorn +165 -0
  24. data/bin/unicorn_rails +208 -0
  25. data/examples/echo.ru +27 -0
  26. data/examples/git.ru +13 -0
  27. data/examples/init.sh +53 -0
  28. data/ext/unicorn_http/c_util.h +107 -0
  29. data/ext/unicorn_http/common_field_optimization.h +111 -0
  30. data/ext/unicorn_http/ext_help.h +73 -0
  31. data/ext/unicorn_http/extconf.rb +14 -0
  32. data/ext/unicorn_http/global_variables.h +91 -0
  33. data/ext/unicorn_http/unicorn_http.rl +715 -0
  34. data/ext/unicorn_http/unicorn_http_common.rl +74 -0
  35. data/lib/unicorn.rb +730 -0
  36. data/lib/unicorn/app/exec_cgi.rb +150 -0
  37. data/lib/unicorn/app/inetd.rb +109 -0
  38. data/lib/unicorn/app/old_rails.rb +31 -0
  39. data/lib/unicorn/app/old_rails/static.rb +60 -0
  40. data/lib/unicorn/cgi_wrapper.rb +145 -0
  41. data/lib/unicorn/configurator.rb +403 -0
  42. data/lib/unicorn/const.rb +37 -0
  43. data/lib/unicorn/http_request.rb +74 -0
  44. data/lib/unicorn/http_response.rb +74 -0
  45. data/lib/unicorn/launcher.rb +39 -0
  46. data/lib/unicorn/socket_helper.rb +138 -0
  47. data/lib/unicorn/tee_input.rb +174 -0
  48. data/lib/unicorn/util.rb +64 -0
  49. data/local.mk.sample +53 -0
  50. data/setup.rb +1586 -0
  51. data/test/aggregate.rb +15 -0
  52. data/test/benchmark/README +50 -0
  53. data/test/benchmark/dd.ru +18 -0
  54. data/test/exec/README +5 -0
  55. data/test/exec/test_exec.rb +855 -0
  56. data/test/rails/app-1.2.3/.gitignore +2 -0
  57. data/test/rails/app-1.2.3/Rakefile +7 -0
  58. data/test/rails/app-1.2.3/app/controllers/application.rb +6 -0
  59. data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +36 -0
  60. data/test/rails/app-1.2.3/app/helpers/application_helper.rb +4 -0
  61. data/test/rails/app-1.2.3/config/boot.rb +11 -0
  62. data/test/rails/app-1.2.3/config/database.yml +12 -0
  63. data/test/rails/app-1.2.3/config/environment.rb +13 -0
  64. data/test/rails/app-1.2.3/config/environments/development.rb +9 -0
  65. data/test/rails/app-1.2.3/config/environments/production.rb +5 -0
  66. data/test/rails/app-1.2.3/config/routes.rb +6 -0
  67. data/test/rails/app-1.2.3/db/.gitignore +0 -0
  68. data/test/rails/app-1.2.3/public/404.html +1 -0
  69. data/test/rails/app-1.2.3/public/500.html +1 -0
  70. data/test/rails/app-2.0.2/.gitignore +2 -0
  71. data/test/rails/app-2.0.2/Rakefile +7 -0
  72. data/test/rails/app-2.0.2/app/controllers/application.rb +4 -0
  73. data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +36 -0
  74. data/test/rails/app-2.0.2/app/helpers/application_helper.rb +4 -0
  75. data/test/rails/app-2.0.2/config/boot.rb +11 -0
  76. data/test/rails/app-2.0.2/config/database.yml +12 -0
  77. data/test/rails/app-2.0.2/config/environment.rb +17 -0
  78. data/test/rails/app-2.0.2/config/environments/development.rb +8 -0
  79. data/test/rails/app-2.0.2/config/environments/production.rb +5 -0
  80. data/test/rails/app-2.0.2/config/routes.rb +6 -0
  81. data/test/rails/app-2.0.2/db/.gitignore +0 -0
  82. data/test/rails/app-2.0.2/public/404.html +1 -0
  83. data/test/rails/app-2.0.2/public/500.html +1 -0
  84. data/test/rails/app-2.1.2/.gitignore +2 -0
  85. data/test/rails/app-2.1.2/Rakefile +7 -0
  86. data/test/rails/app-2.1.2/app/controllers/application.rb +4 -0
  87. data/test/rails/app-2.1.2/app/controllers/foo_controller.rb +36 -0
  88. data/test/rails/app-2.1.2/app/helpers/application_helper.rb +4 -0
  89. data/test/rails/app-2.1.2/config/boot.rb +111 -0
  90. data/test/rails/app-2.1.2/config/database.yml +12 -0
  91. data/test/rails/app-2.1.2/config/environment.rb +17 -0
  92. data/test/rails/app-2.1.2/config/environments/development.rb +7 -0
  93. data/test/rails/app-2.1.2/config/environments/production.rb +5 -0
  94. data/test/rails/app-2.1.2/config/routes.rb +6 -0
  95. data/test/rails/app-2.1.2/db/.gitignore +0 -0
  96. data/test/rails/app-2.1.2/public/404.html +1 -0
  97. data/test/rails/app-2.1.2/public/500.html +1 -0
  98. data/test/rails/app-2.2.2/.gitignore +2 -0
  99. data/test/rails/app-2.2.2/Rakefile +7 -0
  100. data/test/rails/app-2.2.2/app/controllers/application.rb +4 -0
  101. data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +36 -0
  102. data/test/rails/app-2.2.2/app/helpers/application_helper.rb +4 -0
  103. data/test/rails/app-2.2.2/config/boot.rb +111 -0
  104. data/test/rails/app-2.2.2/config/database.yml +12 -0
  105. data/test/rails/app-2.2.2/config/environment.rb +17 -0
  106. data/test/rails/app-2.2.2/config/environments/development.rb +7 -0
  107. data/test/rails/app-2.2.2/config/environments/production.rb +5 -0
  108. data/test/rails/app-2.2.2/config/routes.rb +6 -0
  109. data/test/rails/app-2.2.2/db/.gitignore +0 -0
  110. data/test/rails/app-2.2.2/public/404.html +1 -0
  111. data/test/rails/app-2.2.2/public/500.html +1 -0
  112. data/test/rails/app-2.3.3.1/.gitignore +2 -0
  113. data/test/rails/app-2.3.3.1/Rakefile +7 -0
  114. data/test/rails/app-2.3.3.1/app/controllers/application_controller.rb +5 -0
  115. data/test/rails/app-2.3.3.1/app/controllers/foo_controller.rb +36 -0
  116. data/test/rails/app-2.3.3.1/app/helpers/application_helper.rb +4 -0
  117. data/test/rails/app-2.3.3.1/config/boot.rb +109 -0
  118. data/test/rails/app-2.3.3.1/config/database.yml +12 -0
  119. data/test/rails/app-2.3.3.1/config/environment.rb +17 -0
  120. data/test/rails/app-2.3.3.1/config/environments/development.rb +7 -0
  121. data/test/rails/app-2.3.3.1/config/environments/production.rb +6 -0
  122. data/test/rails/app-2.3.3.1/config/routes.rb +6 -0
  123. data/test/rails/app-2.3.3.1/db/.gitignore +0 -0
  124. data/test/rails/app-2.3.3.1/public/404.html +1 -0
  125. data/test/rails/app-2.3.3.1/public/500.html +1 -0
  126. data/test/rails/app-2.3.3.1/public/x.txt +1 -0
  127. data/test/rails/test_rails.rb +280 -0
  128. data/test/test_helper.rb +296 -0
  129. data/test/unit/test_configurator.rb +150 -0
  130. data/test/unit/test_http_parser.rb +492 -0
  131. data/test/unit/test_http_parser_ng.rb +308 -0
  132. data/test/unit/test_request.rb +184 -0
  133. data/test/unit/test_response.rb +110 -0
  134. data/test/unit/test_server.rb +188 -0
  135. data/test/unit/test_signals.rb +202 -0
  136. data/test/unit/test_socket_helper.rb +133 -0
  137. data/test/unit/test_tee_input.rb +229 -0
  138. data/test/unit/test_upload.rb +297 -0
  139. data/test/unit/test_util.rb +96 -0
  140. data/unicorn.gemspec +42 -0
  141. metadata +228 -0
@@ -0,0 +1,12 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: db/development.sqlite3
4
+ timeout: 5000
5
+ test:
6
+ adapter: sqlite3
7
+ database: db/test.sqlite3
8
+ timeout: 5000
9
+ production:
10
+ adapter: sqlite3
11
+ database: db/production.sqlite3
12
+ timeout: 5000
@@ -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
@@ -0,0 +1,7 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ config.cache_classes = false
4
+ config.whiny_nils = true
5
+ config.action_controller.consider_all_requests_local = true
6
+ config.action_controller.perform_caching = false
7
+ config.action_view.debug_rjs = true
@@ -0,0 +1,5 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ config.cache_classes = true
4
+ config.action_controller.consider_all_requests_local = false
5
+ config.action_controller.perform_caching = true
@@ -0,0 +1,6 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ ActionController::Routing::Routes.draw do |map|
4
+ map.connect ':controller/:action/:id.:format'
5
+ map.connect ':controller/:action/:id'
6
+ end
File without changes
@@ -0,0 +1 @@
1
+ 404 Not Found
@@ -0,0 +1 @@
1
+ 500 Internal Server Error
@@ -0,0 +1,2 @@
1
+ /tmp
2
+ /vendor
@@ -0,0 +1,7 @@
1
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'rake/rdoctask'
6
+
7
+ require 'tasks/rails'
@@ -0,0 +1,4 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ class ApplicationController < ActionController::Base
4
+ end
@@ -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,4 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ module ApplicationHelper
4
+ 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,12 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: db/development.sqlite3
4
+ timeout: 5000
5
+ test:
6
+ adapter: sqlite3
7
+ database: db/test.sqlite3
8
+ timeout: 5000
9
+ production:
10
+ adapter: sqlite3
11
+ database: db/production.sqlite3
12
+ timeout: 5000
@@ -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
@@ -0,0 +1,7 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ config.cache_classes = false
4
+ config.whiny_nils = true
5
+ config.action_controller.consider_all_requests_local = true
6
+ config.action_controller.perform_caching = false
7
+ config.action_view.debug_rjs = true
@@ -0,0 +1,5 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ config.cache_classes = true
4
+ config.action_controller.consider_all_requests_local = false
5
+ config.action_controller.perform_caching = true
@@ -0,0 +1,6 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ ActionController::Routing::Routes.draw do |map|
4
+ map.connect ':controller/:action/:id.:format'
5
+ map.connect ':controller/:action/:id'
6
+ end
File without changes
@@ -0,0 +1 @@
1
+ 404 Not Found
@@ -0,0 +1 @@
1
+ 500 Internal Server Error
@@ -0,0 +1,2 @@
1
+ /tmp
2
+ /vendor
@@ -0,0 +1,7 @@
1
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'rake/rdoctask'
6
+
7
+ require 'tasks/rails'
@@ -0,0 +1,5 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ class ApplicationController < ActionController::Base
4
+ helper :all
5
+ end
@@ -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,4 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ module ApplicationHelper
4
+ 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!