passenger 4.0.45 → 4.0.46

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (94) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/.editorconfig +19 -0
  5. data/CHANGELOG +47 -0
  6. data/CONTRIBUTING.md +9 -1
  7. data/CONTRIBUTORS +4 -0
  8. data/Vagrantfile +7 -3
  9. data/build/agents.rb +1 -0
  10. data/build/misc.rb +6 -4
  11. data/dev/vagrant/bashrc +2 -0
  12. data/doc/Design and Architecture.txt +9 -7
  13. data/doc/Users guide Apache.idmap.txt +2 -0
  14. data/doc/Users guide Apache.txt +24 -4
  15. data/doc/Users guide Nginx.idmap.txt +4 -0
  16. data/doc/Users guide Nginx.txt +23 -4
  17. data/doc/images/code_walkthrough.jpg +0 -0
  18. data/doc/users_guide_snippets/installation.txt +38 -0
  19. data/ext/common/AgentsStarter.h +6 -1
  20. data/ext/common/ApplicationPool2/Common.h +17 -2
  21. data/ext/common/ApplicationPool2/DirectSpawner.h +5 -11
  22. data/ext/common/ApplicationPool2/DummySpawner.h +2 -4
  23. data/ext/common/ApplicationPool2/ErrorRenderer.h +119 -0
  24. data/ext/common/ApplicationPool2/Implementation.cpp +159 -11
  25. data/ext/common/ApplicationPool2/Options.h +16 -7
  26. data/ext/common/ApplicationPool2/Pool.h +28 -24
  27. data/ext/common/ApplicationPool2/Process.h +1 -9
  28. data/ext/common/ApplicationPool2/SmartSpawner.h +15 -18
  29. data/ext/common/ApplicationPool2/Spawner.h +18 -14
  30. data/ext/common/ApplicationPool2/SpawnerFactory.h +12 -30
  31. data/ext/common/Constants.h +1 -1
  32. data/ext/common/Exceptions.h +15 -2
  33. data/ext/common/UnionStation/Core.h +9 -0
  34. data/ext/common/Utils/JsonUtils.h +53 -0
  35. data/ext/common/Utils/ProcessMetricsCollector.h +1 -1
  36. data/ext/common/Utils/SpeedMeter.h +7 -3
  37. data/ext/common/Utils/SystemMetricsCollector.h +8 -6
  38. data/ext/common/agents/HelperAgent/Main.cpp +4 -4
  39. data/ext/common/agents/HelperAgent/RequestHandler.h +115 -56
  40. data/ext/nginx/ConfigurationCommands.c +1 -1
  41. data/ext/nginx/ConfigurationCommands.c.erb +6 -1
  42. data/ext/nginx/ContentHandler.c +2 -1
  43. data/ext/nginx/config +1 -1
  44. data/helper-scripts/node-loader.js +23 -0
  45. data/helper-scripts/wsgi-loader.py +12 -4
  46. data/lib/phusion_passenger.rb +1 -1
  47. data/lib/phusion_passenger/active_support3_extensions/init.rb +39 -78
  48. data/lib/phusion_passenger/constants.rb +3 -1
  49. data/lib/phusion_passenger/loader_shared_helpers.rb +10 -5
  50. data/lib/phusion_passenger/nginx/config_options.rb +3 -1
  51. data/lib/phusion_passenger/packaging.rb +1 -0
  52. data/lib/phusion_passenger/public_api.rb +108 -16
  53. data/lib/phusion_passenger/rack/thread_handler_extension.rb +1 -0
  54. data/lib/phusion_passenger/request_handler.rb +2 -2
  55. data/lib/phusion_passenger/request_handler/thread_handler.rb +28 -46
  56. data/lib/phusion_passenger/standalone/command.rb +8 -1
  57. data/lib/phusion_passenger/standalone/main.rb +0 -1
  58. data/lib/phusion_passenger/standalone/start_command.rb +4 -0
  59. data/lib/phusion_passenger/union_station/connection.rb +67 -0
  60. data/lib/phusion_passenger/{analytics_logger.rb → union_station/core.rb} +55 -256
  61. data/lib/phusion_passenger/union_station/transaction.rb +168 -0
  62. data/lib/phusion_passenger/utils.rb +4 -0
  63. data/lib/phusion_passenger/utils/lock.rb +62 -0
  64. data/resources/mime.types +1 -0
  65. data/resources/templates/error_layout.html.template +2 -0
  66. data/resources/templates/standalone/config.erb +1 -0
  67. data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +5 -3
  68. data/test/cxx/ApplicationPool2/PoolTest.cpp +13 -3
  69. data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +16 -13
  70. data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +6 -0
  71. data/test/cxx/FileBackedPipeTest.cpp +1 -1
  72. data/test/cxx/RequestHandlerTest.cpp +158 -2
  73. data/test/cxx/ServerInstanceDirTest.cpp +2 -0
  74. data/test/cxx/TestSupport.h +21 -2
  75. data/test/cxx/UtilsTest.cpp +1 -0
  76. data/test/ruby/classic_rails/loader_spec.rb +0 -1
  77. data/test/ruby/classic_rails/preloader_spec.rb +0 -1
  78. data/test/ruby/rails3.0/loader_spec.rb +2 -2
  79. data/test/ruby/rails3.0/preloader_spec.rb +2 -2
  80. data/test/ruby/rails3.1/loader_spec.rb +2 -2
  81. data/test/ruby/rails3.1/preloader_spec.rb +2 -2
  82. data/test/ruby/rails3.2/loader_spec.rb +2 -2
  83. data/test/ruby/rails3.2/preloader_spec.rb +2 -2
  84. data/test/ruby/rails4.0/loader_spec.rb +2 -2
  85. data/test/ruby/rails4.0/preloader_spec.rb +2 -2
  86. data/test/ruby/request_handler_spec.rb +8 -8
  87. data/test/ruby/shared/rails/{analytics_logging_extensions_sharedspec.rb → union_station_extensions_sharedspec.rb} +5 -4
  88. data/test/ruby/union_station_spec.rb +283 -0
  89. data/test/stub/wsgi/passenger_wsgi.py +41 -5
  90. metadata +12 -7
  91. metadata.gz.asc +7 -7
  92. data/helper-scripts/wsgi-preloader.py +0 -1
  93. data/lib/phusion_passenger/standalone/package_runtime_command.rb +0 -105
  94. data/test/ruby/analytics_logger_spec.rb +0 -283
metadata.gz.asc CHANGED
@@ -2,11 +2,11 @@
2
2
  Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
3
3
  Comment: GPGTools - http://gpgtools.org
4
4
 
5
- iQEcBAABAgAGBQJTmYzGAAoJECrHRaUKISqMNuEIAJ0KBHgumSlkufhMIDJH0ive
6
- jSKD7jiWPsi8SyBOl5ohnr9QJMmO3L77WUt8AM7gLy9D0XHBd9FlzktzngEyAEJn
7
- NnXhDZyTKQLai2qmNFnYa/N8EMfVQ0Hz4e7aqima3DLrUkKVoGhXm//duU3Tjn5b
8
- rjPp1GKAfUIS7zHSOygQ0nZE+n1RlHpV3D0vKkf+3HYOxBFOGd7lwLb3HNZ7MO4M
9
- GuW3vmkYWDJnJbw1B5xI3MiHuwdRVY5ekTKBlTuoHkjn44rQyQfN3iDvBg73Pnb3
10
- 3oe+8qru2B7GvvRWveM8/16ey73Z3K49mMhVD1i+tBYnGW8wAN0b1H/SFVDp3fk=
11
- =Kul/
5
+ iQEcBAABAgAGBQJTxCOxAAoJECrHRaUKISqMXVwIAI0rKA8XrET+UEEZxdg0KApM
6
+ 9To5MBumjeAEjNifX89upFHpSw+pXbOGz0xggl8h1y0axsDL8fQuXS7nWKWy4o6u
7
+ FbOBo3BBH9Ji0e6G/LlPe2NbYGxHLGUEmFER1/qXwO4PffdR3+gRnjEJEucs4aPJ
8
+ 1qbrne5R3svh2vRFnzJMRHdP8cBYXz1DS/DK4xY0aQ10RK6Ah7C2zrhTBudezqUp
9
+ dXnnDa8Pcc/i0j1v2bZISOYp7nwhs+akf+c9/z3dZBpoIDPN2USt5IMyb5B4/ueT
10
+ SFgRk/kStS95XwIlAb6a+PzDGjEfL/qVxVjQDb2GjgihP7vQEzWMzeTumbZa16g=
11
+ =k1B4
12
12
  -----END PGP SIGNATURE-----
@@ -1 +0,0 @@
1
- #!/usr/bin/env python
@@ -1,105 +0,0 @@
1
- # encoding: utf-8
2
- # Phusion Passenger - https://www.phusionpassenger.com/
3
- # Copyright (c) 2010 Phusion
4
- #
5
- # "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the "Software"), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in
15
- # all copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- # THE SOFTWARE.
24
-
25
- module PhusionPassenger
26
- module Standalone
27
-
28
- class PackageRuntimeCommand < Command
29
- def self.description
30
- return "Package the Phusion Passenger Standalone runtime."
31
- end
32
-
33
- def self.require_libs
34
- PhusionPassenger.require_passenger_lib 'platform_info/binary_compatibility'
35
- PhusionPassenger.require_passenger_lib 'standalone/runtime_installer'
36
- end
37
-
38
- def run
39
- destdir = File.expand_path("passenger-standalone")
40
- description =
41
- "Package the Phusion Passenger Standalone runtime into the specified directory.\n" <<
42
- "If DIRECTORY is not given then #{destdir} will be used."
43
- parse_options!("package [directory]", description) do |opts|
44
- opts.separator "Options:"
45
- opts.on("--nginx-version VERSION", String,
46
- wrap_desc("Nginx version to use as core (default: #{@options[:nginx_version]})")) do |value|
47
- @options[:nginx_version] = value
48
- end
49
- opts.on("--nginx-tarball FILENAME", String,
50
- wrap_desc("Use the given tarball instead of downloading from the Internet. " +
51
- "This tarball *must* match the version specified by --nginx-version!")) do |value|
52
- @options[:nginx_tarball] = value
53
- end
54
- end
55
-
56
- destdir = File.expand_path(@args[0]) if @args[0]
57
- runtime_dir = "#{destdir}/#{PhusionPassenger::VERSION_STRING}"
58
- support_dir = "#{runtime_dir}/support-#{PlatformInfo.cxx_binary_compatibility_id}"
59
- ruby_dir = "#{runtime_dir}/rubyext-#{PlatformInfo.ruby_extension_binary_compatibility_id}"
60
- nginx_dir = "#{runtime_dir}/nginx-#{@options[:nginx_version]}-#{PlatformInfo.cxx_binary_compatibility_id}"
61
-
62
- sh "rm", "-rf", support_dir
63
- sh "rm", "-rf", nginx_dir
64
-
65
- installer = RuntimeInstaller.new(
66
- :targets => [:nginx, :ruby, :support_binaries],
67
- :support_dir => support_dir,
68
- :ruby_dir => ruby_dir,
69
- :nginx_dir => nginx_dir,
70
- :nginx_version => @options[:nginx_version],
71
- :nginx_tarball => @options[:nginx_tarball],
72
- :download_binaries => false)
73
- installer.run
74
-
75
- Dir.chdir(support_dir) do
76
- support_dir_name = File.basename(support_dir)
77
- puts "cd #{support_dir}"
78
- sh "tar -c . | gzip --best > ../#{support_dir_name}.tar.gz"
79
- end
80
- Dir.chdir(ruby_dir) do
81
- ruby_dir_name = File.basename(ruby_dir)
82
- puts "cd #{ruby_dir}"
83
- sh "tar -c . | gzip --best > ../#{ruby_dir_name}.tar.gz"
84
- end
85
- Dir.chdir(nginx_dir) do
86
- nginx_dir_name = File.basename(nginx_dir)
87
- puts "cd #{nginx_dir}"
88
- sh "tar -c . | gzip --best > ../#{nginx_dir_name}.tar.gz"
89
- end
90
- puts "cd #{runtime_dir}"
91
- sh "rm", "-rf", support_dir, ruby_dir, nginx_dir
92
- end
93
-
94
- private
95
- def sh(*args)
96
- puts args.join(' ')
97
- if !system(*args)
98
- STDERR.puts "*** Cannot run command: #{args.join(' ')}"
99
- exit 1
100
- end
101
- end
102
- end
103
-
104
- end
105
- end
@@ -1,283 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'stringio'
3
- PhusionPassenger.require_passenger_lib 'analytics_logger'
4
-
5
- module PhusionPassenger
6
-
7
- describe AnalyticsLogger do
8
- YESTERDAY = Time.utc(2010, 4, 11, 11, 56, 02)
9
- TODAY = Time.utc(2010, 4, 11, 12, 56, 02)
10
- TOMORROW = Time.utc(2010, 4, 11, 13, 56, 02)
11
-
12
- before :each do
13
- @username = "logging"
14
- @password = "1234"
15
- @dump_file = Utils.passenger_tmpdir + "/log.txt"
16
- start_agent
17
- @logger = AnalyticsLogger.new(@socket_address, @username, @password, "localhost")
18
- @logger2 = AnalyticsLogger.new(@socket_address, @username, @password, "localhost")
19
- end
20
-
21
- after :each do
22
- @logger.close
23
- @logger2.close
24
- if @agent_pid
25
- Process.kill('KILL', @agent_pid)
26
- Process.waitpid(@agent_pid)
27
- end
28
- end
29
-
30
- def mock_time(time)
31
- AnalyticsLogger.stub(:current_time).and_return(time)
32
- end
33
-
34
- def start_agent
35
- @agent_pid, @socket_filename, @socket_address = spawn_logging_agent(@dump_file, @password)
36
- end
37
-
38
- def kill_agent
39
- if @agent_pid
40
- Process.kill('KILL', @agent_pid)
41
- Process.waitpid(@agent_pid)
42
- File.unlink(@socket_filename)
43
- @agent_pid = nil
44
- end
45
- end
46
-
47
- specify "logging with #new_transaction works" do
48
- mock_time(TODAY)
49
-
50
- log = @logger.new_transaction("foobar")
51
- log.should_not be_null
52
- begin
53
- log.message("hello")
54
- ensure
55
- log.close(true)
56
- end
57
-
58
- File.read(@dump_file).should =~ /hello/
59
-
60
- log = @logger.new_transaction("foobar", :processes)
61
- log.should_not be_null
62
- begin
63
- log.message("world")
64
- ensure
65
- log.close(true)
66
- end
67
-
68
- File.read(@dump_file).should =~ /world/
69
- end
70
-
71
- specify "#new_transaction reestablishes the connection if disconnected" do
72
- mock_time(TODAY)
73
-
74
- @logger.new_transaction("foobar").close(true)
75
- connection = @logger.instance_variable_get(:"@connection")
76
- connection.synchronize do
77
- connection.channel.close
78
- connection.channel = nil
79
- end
80
-
81
- log = @logger.new_transaction("foobar")
82
- begin
83
- log.message("hello")
84
- ensure
85
- log.close(true)
86
- end
87
-
88
- File.read(@dump_file).should =~ /hello/
89
- end
90
-
91
- specify "#new_transaction does not reconnect to the server for a short period of time if connecting failed" do
92
- @logger.reconnect_timeout = 60
93
- @logger.max_connect_tries = 1
94
-
95
- mock_time(TODAY)
96
- kill_agent
97
- @logger.new_transaction("foobar").should be_null
98
-
99
- mock_time(TODAY + 30)
100
- start_agent
101
- @logger.new_transaction("foobar").should be_null
102
-
103
- mock_time(TODAY + 61)
104
- @logger.new_transaction("foobar").should_not be_null
105
- end
106
-
107
- specify "logging with #continue_transaction works" do
108
- mock_time(TODAY)
109
-
110
- log = @logger.new_transaction("foobar", :processes)
111
- begin
112
- log.message("hello")
113
- log2 = @logger2.continue_transaction(log.txn_id, "foobar", :processes)
114
- log2.should_not be_null
115
- log2.txn_id.should == log.txn_id
116
- begin
117
- log2.message("world")
118
- ensure
119
- log2.close(true)
120
- end
121
- ensure
122
- log.close(true)
123
- end
124
-
125
- File.read(@dump_file).should =~ /#{Regexp.escape log.txn_id} .* hello$/
126
- File.read(@dump_file).should =~ /#{Regexp.escape log.txn_id} .* world$/
127
- end
128
-
129
- specify "#continue_transaction reestablishes the connection if disconnected" do
130
- mock_time(TODAY)
131
-
132
- log = @logger.new_transaction("foobar")
133
- log.close(true)
134
- log2 = @logger2.continue_transaction(log.txn_id, "foobar")
135
- log2.close(true)
136
-
137
- connection = @logger2.instance_variable_get(:"@connection")
138
- connection.synchronize do
139
- connection.channel.close
140
- connection.channel = nil
141
- end
142
-
143
- log2 = @logger2.continue_transaction(log.txn_id, "foobar")
144
- begin
145
- log2.message("hello")
146
- ensure
147
- log2.close(true)
148
- end
149
-
150
- File.read(@dump_file).should =~ /hello/
151
- end
152
-
153
- specify "#new_transaction and #continue_transaction eventually reestablish the connection to the logging server if the logging server crashed and was restarted" do
154
- mock_time(TODAY)
155
-
156
- log = @logger.new_transaction("foobar")
157
- @logger2.continue_transaction(log.txn_id, "foobar").close
158
- kill_agent
159
- start_agent
160
-
161
- log = @logger.new_transaction("foobar")
162
- log.should be_null
163
- log2 = @logger2.continue_transaction("1234-abcd", "foobar")
164
- log2.should be_null
165
-
166
- mock_time(TODAY + 60)
167
- log = @logger.new_transaction("foobar")
168
- log2 = @logger2.continue_transaction(log.txn_id, "foobar")
169
- begin
170
- log2.message("hello")
171
- ensure
172
- log2.close(true)
173
- end
174
- log.close(true)
175
-
176
- File.read(@dump_file).should =~ /hello/
177
- end
178
-
179
- specify "#continue_transaction does not reconnect to the server for a short period of time if connecting failed" do
180
- @logger.reconnect_timeout = 60
181
- @logger.max_connect_tries = 1
182
- @logger2.reconnect_timeout = 60
183
- @logger2.max_connect_tries = 1
184
-
185
- mock_time(TODAY)
186
- log = @logger.new_transaction("foobar")
187
- @logger2.continue_transaction(log.txn_id, "foobar")
188
- kill_agent
189
- @logger2.continue_transaction(log.txn_id, "foobar").should be_null
190
-
191
- mock_time(TODAY + 30)
192
- start_agent
193
- @logger2.continue_transaction(log.txn_id, "foobar").should be_null
194
-
195
- mock_time(TODAY + 61)
196
- @logger2.continue_transaction(log.txn_id, "foobar").should_not be_null
197
- end
198
-
199
- specify "AnalyticsLogger only creates null Log objects if no server address is given" do
200
- logger = AnalyticsLogger.new(nil, nil, nil, nil)
201
- begin
202
- logger.new_transaction("foobar").should be_null
203
- ensure
204
- logger.close
205
- end
206
- end
207
-
208
- specify "#clear_connection closes the connection" do
209
- @logger.new_transaction("foobar").close
210
- @logger.clear_connection
211
- connection = @logger.instance_variable_get(:"@connection")
212
- connection.synchronize do
213
- connection.channel.should be_nil
214
- end
215
- end
216
-
217
- describe "Log objects" do
218
- it "becomes null once it is closed" do
219
- log = @logger.new_transaction("foobar")
220
- log.close
221
- log.should be_null
222
- end
223
-
224
- it "does nothing if it's null" do
225
- logger = AnalyticsLogger.new(nil, nil, nil, nil)
226
- begin
227
- log = logger.new_transaction("foobar")
228
- log.message("hello")
229
- log.close(true)
230
- ensure
231
- logger.close
232
- end
233
-
234
- File.exist?("#{@log_dir}/1").should be_false
235
- end
236
-
237
- describe "#begin_measure" do
238
- it "sends a BEGIN message" do
239
- log = @logger.new_transaction("foobar")
240
- begin
241
- log.should_receive(:message).with(/^BEGIN: hello \(.+?,.+?,.+?\) $/)
242
- log.begin_measure("hello")
243
- ensure
244
- log.close
245
- end
246
- end
247
-
248
- it "adds extra information as base64" do
249
- log = @logger.new_transaction("foobar")
250
- begin
251
- log.should_receive(:message).with(/^BEGIN: hello \(.+?,.+?,.+?\) YWJjZA==$/)
252
- log.begin_measure("hello", "abcd")
253
- ensure
254
- log.close
255
- end
256
- end
257
- end
258
-
259
- describe "#end_measure" do
260
- it "sends an END message if error_countered=false" do
261
- log = @logger.new_transaction("foobar")
262
- begin
263
- log.should_receive(:message).with(/^END: hello \(.+?,.+?,.+?\)$/)
264
- log.end_measure("hello")
265
- ensure
266
- log.close
267
- end
268
- end
269
-
270
- it "sends a FAIL message if error_countered=true" do
271
- log = @logger.new_transaction("foobar")
272
- begin
273
- log.should_receive(:message).with(/^FAIL: hello \(.+?,.+?,.+?\)$/)
274
- log.end_measure("hello", true)
275
- ensure
276
- log.close
277
- end
278
- end
279
- end
280
- end
281
- end
282
-
283
- end # module PhusionPassenger