passenger 5.0.0.beta3 → 5.0.0.rc1
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.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/.editorconfig +11 -5
- data/CHANGELOG +38 -0
- data/CONTRIBUTING.md +1 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +0 -2
- data/Rakefile +33 -33
- data/bin/passenger +1 -1
- data/bin/passenger-config +1 -1
- data/bin/passenger-install-apache2-module +800 -800
- data/bin/passenger-install-nginx-module +592 -592
- data/bin/passenger-memory-stats +127 -127
- data/bin/passenger-status +216 -216
- data/build/agents.rb +127 -127
- data/build/apache2.rb +87 -87
- data/build/basics.rb +60 -60
- data/build/common_library.rb +165 -165
- data/build/cplusplus_support.rb +51 -51
- data/build/cxx_tests.rb +268 -268
- data/build/debian.rb +143 -143
- data/build/documentation.rb +58 -58
- data/build/integration_tests.rb +81 -81
- data/build/misc.rb +132 -132
- data/build/nginx.rb +20 -20
- data/build/node_tests.rb +7 -7
- data/build/oxt_tests.rb +14 -14
- data/build/packaging.rb +570 -570
- data/build/preprocessor.rb +260 -260
- data/build/rake_extensions.rb +71 -71
- data/build/ruby_extension.rb +29 -29
- data/build/ruby_tests.rb +6 -6
- data/build/test_basics.rb +37 -37
- data/debian.template/control.template +3 -5
- data/dev/copy_boost_headers +134 -134
- data/dev/install_scripts_bootstrap_code.rb +25 -25
- data/dev/list_tests +20 -20
- data/dev/ruby_server.rb +223 -223
- data/dev/runner +18 -18
- data/doc/ServerOptimizationGuide.txt.md +55 -2
- data/doc/Users guide Nginx.txt +0 -26
- data/doc/Users guide Standalone.txt +5 -1
- data/doc/users_guide_snippets/tips.txt +9 -0
- data/ext/common/ApplicationPool2/Group.h +23 -11
- data/ext/common/ApplicationPool2/Implementation.cpp +32 -7
- data/ext/common/ApplicationPool2/Pool.h +22 -17
- data/ext/common/ApplicationPool2/SmartSpawner.h +4 -1
- data/ext/common/ApplicationPool2/Spawner.h +1 -1
- data/ext/common/Constants.h +1 -1
- data/ext/common/agents/Base.cpp +35 -20
- data/ext/common/agents/HelperAgent/Main.cpp +8 -1
- data/ext/common/agents/HelperAgent/OptionParser.h +18 -4
- data/ext/common/agents/HelperAgent/RequestHandler.h +2 -83
- data/ext/common/agents/HelperAgent/RequestHandler/ForwardResponse.cpp +54 -1
- data/ext/common/agents/HelperAgent/RequestHandler/InitRequest.cpp +7 -4
- data/ext/common/agents/Main.cpp +1 -1
- data/ext/common/agents/Watchdog/Main.cpp +54 -19
- data/ext/nginx/Configuration.c +7 -0
- data/ext/nginx/ContentHandler.c +9 -1
- data/helper-scripts/backtrace-sanitizer.rb +106 -87
- data/helper-scripts/crash-watch.rb +32 -0
- data/helper-scripts/download_binaries/extconf.rb +38 -38
- data/helper-scripts/meteor-loader.rb +107 -107
- data/helper-scripts/prespawn +101 -101
- data/helper-scripts/rack-loader.rb +96 -96
- data/helper-scripts/rack-preloader.rb +137 -137
- data/lib/phusion_passenger.rb +292 -292
- data/lib/phusion_passenger/abstract_installer.rb +438 -438
- data/lib/phusion_passenger/active_support3_extensions/init.rb +168 -170
- data/lib/phusion_passenger/admin_tools.rb +20 -20
- data/lib/phusion_passenger/admin_tools/instance.rb +178 -178
- data/lib/phusion_passenger/admin_tools/instance_registry.rb +61 -61
- data/lib/phusion_passenger/admin_tools/memory_stats.rb +267 -267
- data/lib/phusion_passenger/apache2/config_options.rb +182 -182
- data/lib/phusion_passenger/common_library.rb +479 -485
- data/lib/phusion_passenger/config/about_command.rb +161 -161
- data/lib/phusion_passenger/config/admin_command_command.rb +129 -129
- data/lib/phusion_passenger/config/agent_compiler.rb +121 -121
- data/lib/phusion_passenger/config/build_native_support_command.rb +43 -43
- data/lib/phusion_passenger/config/command.rb +25 -25
- data/lib/phusion_passenger/config/compile_agent_command.rb +62 -62
- data/lib/phusion_passenger/config/compile_nginx_engine_command.rb +88 -73
- data/lib/phusion_passenger/config/detach_process_command.rb +72 -72
- data/lib/phusion_passenger/config/download_agent_command.rb +246 -227
- data/lib/phusion_passenger/config/download_nginx_engine_command.rb +245 -224
- data/lib/phusion_passenger/config/install_agent_command.rb +144 -132
- data/lib/phusion_passenger/config/install_standalone_runtime_command.rb +205 -185
- data/lib/phusion_passenger/config/installation_utils.rb +204 -204
- data/lib/phusion_passenger/config/list_instances_command.rb +64 -64
- data/lib/phusion_passenger/config/main.rb +152 -152
- data/lib/phusion_passenger/config/nginx_engine_compiler.rb +319 -300
- data/lib/phusion_passenger/config/reopen_logs_command.rb +67 -67
- data/lib/phusion_passenger/config/restart_app_command.rb +155 -155
- data/lib/phusion_passenger/config/system_metrics_command.rb +13 -13
- data/lib/phusion_passenger/config/utils.rb +95 -95
- data/lib/phusion_passenger/config/validate_install_command.rb +198 -198
- data/lib/phusion_passenger/console_text_template.rb +25 -25
- data/lib/phusion_passenger/constants.rb +90 -90
- data/lib/phusion_passenger/debug_logging.rb +106 -106
- data/lib/phusion_passenger/loader_shared_helpers.rb +447 -432
- data/lib/phusion_passenger/message_channel.rb +312 -312
- data/lib/phusion_passenger/message_client.rb +176 -176
- data/lib/phusion_passenger/native_support.rb +369 -369
- data/lib/phusion_passenger/nginx/config_options.rb +297 -297
- data/lib/phusion_passenger/packaging.rb +131 -131
- data/lib/phusion_passenger/platform_info.rb +360 -360
- data/lib/phusion_passenger/platform_info/apache.rb +767 -767
- data/lib/phusion_passenger/platform_info/apache_detector.rb +199 -199
- data/lib/phusion_passenger/platform_info/binary_compatibility.rb +107 -107
- data/lib/phusion_passenger/platform_info/compiler.rb +570 -570
- data/lib/phusion_passenger/platform_info/curl.rb +32 -32
- data/lib/phusion_passenger/platform_info/cxx_portability.rb +188 -188
- data/lib/phusion_passenger/platform_info/depcheck.rb +372 -372
- data/lib/phusion_passenger/platform_info/depcheck_specs/apache2.rb +109 -109
- data/lib/phusion_passenger/platform_info/depcheck_specs/compiler_toolchain.rb +4 -4
- data/lib/phusion_passenger/platform_info/depcheck_specs/gems.rb +10 -34
- data/lib/phusion_passenger/platform_info/depcheck_specs/libs.rb +101 -101
- data/lib/phusion_passenger/platform_info/depcheck_specs/ruby.rb +5 -5
- data/lib/phusion_passenger/platform_info/depcheck_specs/utilities.rb +13 -13
- data/lib/phusion_passenger/platform_info/linux.rb +55 -55
- data/lib/phusion_passenger/platform_info/operating_system.rb +149 -149
- data/lib/phusion_passenger/platform_info/ruby.rb +468 -448
- data/lib/phusion_passenger/platform_info/zlib.rb +9 -9
- data/lib/phusion_passenger/plugin.rb +66 -66
- data/lib/phusion_passenger/preloader_shared_helpers.rb +126 -126
- data/lib/phusion_passenger/public_api.rb +191 -191
- data/lib/phusion_passenger/rack/out_of_band_gc.rb +93 -94
- data/lib/phusion_passenger/rack/thread_handler_extension.rb +231 -227
- data/lib/phusion_passenger/request_handler.rb +567 -577
- data/lib/phusion_passenger/request_handler/thread_handler.rb +379 -381
- data/lib/phusion_passenger/ruby_core_enhancements.rb +86 -86
- data/lib/phusion_passenger/ruby_core_io_enhancements.rb +74 -74
- data/lib/phusion_passenger/simple_benchmarking.rb +25 -25
- data/lib/phusion_passenger/standalone/app_finder.rb +153 -150
- data/lib/phusion_passenger/standalone/command.rb +44 -40
- data/lib/phusion_passenger/standalone/config_utils.rb +53 -53
- data/lib/phusion_passenger/standalone/control_utils.rb +38 -59
- data/lib/phusion_passenger/standalone/main.rb +73 -73
- data/lib/phusion_passenger/standalone/start_command.rb +697 -685
- data/lib/phusion_passenger/standalone/start_command/builtin_engine.rb +193 -155
- data/lib/phusion_passenger/standalone/start_command/nginx_engine.rb +162 -133
- data/lib/phusion_passenger/standalone/status_command.rb +64 -64
- data/lib/phusion_passenger/standalone/stop_command.rb +72 -72
- data/lib/phusion_passenger/standalone/version_command.rb +9 -9
- data/lib/phusion_passenger/union_station/connection.rb +32 -32
- data/lib/phusion_passenger/union_station/core.rb +251 -251
- data/lib/phusion_passenger/union_station/transaction.rb +126 -126
- data/lib/phusion_passenger/utils.rb +199 -167
- data/lib/phusion_passenger/utils/ansi_colors.rb +128 -128
- data/lib/phusion_passenger/utils/download.rb +196 -196
- data/lib/phusion_passenger/utils/file_system_watcher.rb +158 -158
- data/lib/phusion_passenger/utils/hosts_file_parser.rb +101 -101
- data/lib/phusion_passenger/utils/lock.rb +31 -31
- data/lib/phusion_passenger/utils/native_support_utils.rb +31 -31
- data/lib/phusion_passenger/utils/progress_bar.rb +26 -26
- data/lib/phusion_passenger/utils/shellwords.rb +20 -20
- data/lib/phusion_passenger/utils/terminal_choice_menu.rb +206 -206
- data/lib/phusion_passenger/utils/unseekable_socket.rb +272 -272
- data/lib/phusion_passenger/vendor/crash_watch/app.rb +129 -0
- data/lib/phusion_passenger/vendor/crash_watch/gdb_controller.rb +341 -0
- data/lib/phusion_passenger/vendor/crash_watch/version.rb +24 -0
- data/lib/phusion_passenger/vendor/daemon_controller.rb +877 -0
- data/lib/phusion_passenger/vendor/daemon_controller/lock_file.rb +127 -0
- data/lib/phusion_passenger/vendor/daemon_controller/spawn.rb +26 -0
- data/lib/phusion_passenger/vendor/daemon_controller/version.rb +29 -0
- data/packaging/rpm/passenger_spec/passenger.spec.template +0 -1
- data/passenger.gemspec +0 -1
- data/resources/templates/config/nginx_engine_compiler/possible_solutions_for_download_and_extraction_problems.txt.erb +27 -0
- data/resources/templates/standalone/config.erb +19 -15
- data/test/integration_tests/apache2_tests.rb +566 -566
- data/test/integration_tests/downloaded_binaries_tests.rb +126 -125
- data/test/integration_tests/native_packaging_spec.rb +296 -296
- data/test/integration_tests/nginx_tests.rb +393 -393
- data/test/integration_tests/shared/example_webapp_tests.rb +282 -280
- data/test/integration_tests/source_packaging_test.rb +138 -138
- data/test/integration_tests/spec_helper.rb +5 -5
- data/test/integration_tests/standalone_tests.rb +367 -367
- data/test/ruby/debug_logging_spec.rb +133 -133
- data/test/ruby/message_channel_spec.rb +186 -186
- data/test/ruby/rack/loader_spec.rb +28 -28
- data/test/ruby/rack/preloader_spec.rb +34 -34
- data/test/ruby/rails3.0/loader_spec.rb +12 -12
- data/test/ruby/rails3.0/preloader_spec.rb +18 -18
- data/test/ruby/rails3.1/loader_spec.rb +12 -12
- data/test/ruby/rails3.1/preloader_spec.rb +18 -18
- data/test/ruby/rails3.2/loader_spec.rb +12 -12
- data/test/ruby/rails3.2/preloader_spec.rb +18 -18
- data/test/ruby/rails4.0/loader_spec.rb +12 -12
- data/test/ruby/rails4.0/preloader_spec.rb +18 -18
- data/test/ruby/rails4.1/loader_spec.rb +12 -12
- data/test/ruby/rails4.1/preloader_spec.rb +18 -18
- data/test/ruby/request_handler_spec.rb +730 -730
- data/test/ruby/shared/loader_sharedspec.rb +224 -224
- data/test/ruby/shared/rails/union_station_extensions_sharedspec.rb +327 -327
- data/test/ruby/shared/ruby_loader_sharedspec.rb +47 -47
- data/test/ruby/spec_helper.rb +65 -65
- data/test/ruby/standalone/runtime_installer_spec.rb +384 -384
- data/test/ruby/union_station_spec.rb +276 -276
- data/test/ruby/utils/file_system_watcher_spec.rb +220 -220
- data/test/ruby/utils/hosts_file_parser.rb +248 -248
- data/test/ruby/utils/tee_input_spec.rb +215 -215
- data/test/ruby/utils/unseekable_socket_spec.rb +57 -57
- data/test/ruby/utils_spec.rb +21 -21
- data/test/stub/rack/config.ru +87 -87
- data/test/stub/rack/library.rb +8 -8
- data/test/stub/rack/start.rb +30 -30
- data/test/support/apache2_controller.rb +191 -191
- data/test/support/nginx_controller.rb +90 -99
- data/test/support/placebo-preloader.rb +57 -57
- data/test/support/test_helper.rb +435 -435
- metadata +11 -21
- metadata.gz.asc +7 -7
- data/lib/phusion_passenger/standalone/command2.rb +0 -292
- data/lib/phusion_passenger/standalone/start2_command.rb +0 -799
- data/resources/templates/standalone/download_tool_missing.txt.erb +0 -18
- data/resources/templates/standalone/possible_solutions_for_download_and_extraction_problems.txt.erb +0 -17
- data/resources/templates/standalone/run_installer_as_root.txt.erb +0 -8
@@ -1,5 +1,6 @@
|
|
1
|
+
# encoding: binary
|
1
2
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
-
# Copyright (c) 2010 Phusion
|
3
|
+
# Copyright (c) 2010-2015 Phusion
|
3
4
|
#
|
4
5
|
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
5
6
|
#
|
@@ -28,452 +29,471 @@ PhusionPassenger.require_passenger_lib 'platform_info/operating_system'
|
|
28
29
|
|
29
30
|
module PhusionPassenger
|
30
31
|
|
31
|
-
module PlatformInfo
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
32
|
+
module PlatformInfo
|
33
|
+
# Store original $GEM_HOME value so that even if the app customizes
|
34
|
+
# $GEM_HOME we can still work with the original value.
|
35
|
+
gem_home = ENV['GEM_HOME']
|
36
|
+
if gem_home
|
37
|
+
gem_home = gem_home.strip.freeze
|
38
|
+
gem_home = nil if gem_home.empty?
|
39
|
+
end
|
40
|
+
GEM_HOME = gem_home
|
41
|
+
|
42
|
+
# Ditto for $GEM_PATH
|
43
|
+
gem_path = ENV['GEM_PATH']
|
44
|
+
if gem_path
|
45
|
+
gem_path = gem_path.strip.freeze
|
46
|
+
gem_path = nil if gem_path.empty?
|
47
|
+
end
|
48
|
+
GEM_PATH = gem_path
|
49
|
+
|
50
|
+
if defined?(::RUBY_ENGINE)
|
51
|
+
RUBY_ENGINE = ::RUBY_ENGINE
|
52
|
+
else
|
53
|
+
RUBY_ENGINE = "ruby"
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns correct command for invoking the current Ruby interpreter.
|
57
|
+
# In case of RVM this function will return the path to the RVM wrapper script
|
58
|
+
# that executes the current Ruby interpreter in the currently active gem set.
|
59
|
+
def self.ruby_command
|
60
|
+
# Detect usage of gem-wrappers: https://github.com/rvm/gem-wrappers
|
61
|
+
# This is currently used by RVM >= 1.25, although it's not exclusive to RVM.
|
62
|
+
if GEM_HOME && File.exist?("#{GEM_HOME}/wrappers/ruby")
|
63
|
+
return "#{GEM_HOME}/wrappers/ruby"
|
64
|
+
end
|
65
|
+
|
66
|
+
if in_rvm?
|
67
|
+
# Detect old-school RVM wrapper script location.
|
68
|
+
name = rvm_ruby_string
|
69
|
+
dirs = rvm_paths
|
70
|
+
if name && dirs
|
71
|
+
dirs.each do |dir|
|
72
|
+
filename = "#{dir}/wrappers/#{name}/ruby"
|
73
|
+
if File.exist?(filename)
|
74
|
+
contents = File.open(filename, 'rb') do |f|
|
75
|
+
f.read
|
76
|
+
end
|
77
|
+
# Old wrapper scripts reference $HOME which causes
|
78
|
+
# things to blow up when run by a different user.
|
79
|
+
if contents.include?("$HOME")
|
80
|
+
filename = nil
|
81
|
+
end
|
82
|
+
else
|
83
|
+
filename = nil
|
84
|
+
end
|
85
|
+
if filename
|
86
|
+
return filename
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Correctness of these commands are confirmed by mpapis.
|
91
|
+
# If we ever encounter a case for which this logic is not sufficient,
|
92
|
+
# try mpapis' pseudo code:
|
93
|
+
#
|
94
|
+
# rvm_update_prefix = write_to rvm_path ? "" : "rvmsudo"
|
95
|
+
# rvm_gemhome_prefix = write_to GEM_HOME ? "" : "rvmsudo"
|
96
|
+
# repair_command = "#{rvm_update_prefix} rvm get stable && rvm reload && #{rvm_gemhome_prefix} rvm repair all"
|
97
|
+
# wrapper_command = "#{rvm_gemhome_prefix} rvm wrapper #{rvm_ruby_string} --no-prefix --all"
|
98
|
+
case rvm_installation_mode
|
99
|
+
when :single
|
100
|
+
repair_command = "rvm get stable && rvm reload && rvm repair all"
|
101
|
+
wrapper_command = "rvm wrapper #{rvm_ruby_string} --no-prefix --all"
|
102
|
+
when :multi
|
103
|
+
repair_command = "rvmsudo rvm get stable && rvm reload && rvmsudo rvm repair all"
|
104
|
+
wrapper_command = "rvmsudo rvm wrapper #{rvm_ruby_string} --no-prefix --all"
|
105
|
+
when :mixed
|
106
|
+
repair_command = "rvmsudo rvm get stable && rvm reload && rvm repair all"
|
107
|
+
wrapper_command = "rvm wrapper #{rvm_ruby_string} --no-prefix --all"
|
108
|
+
end
|
109
|
+
|
110
|
+
STDERR.puts "Your RVM wrapper scripts are too old, or some " +
|
111
|
+
"wrapper scripts are missing. Please update/regenerate " +
|
112
|
+
"them first by running:\n\n" +
|
113
|
+
" #{repair_command}\n\n" +
|
114
|
+
"If that doesn't seem to work, please run:\n\n" +
|
115
|
+
" #{wrapper_command}"
|
116
|
+
exit 1
|
117
|
+
else
|
118
|
+
# Something's wrong with the user's RVM installation.
|
119
|
+
# Raise an error so that the user knows this instead of
|
120
|
+
# having things fail randomly later on.
|
121
|
+
# 'name' is guaranteed to be non-nil because rvm_ruby_string
|
122
|
+
# already raises an exception on error.
|
123
|
+
STDERR.puts "Your RVM installation appears to be broken: the RVM " +
|
124
|
+
"path cannot be found. Please fix your RVM installation " +
|
125
|
+
"or contact the RVM developers for support."
|
126
|
+
exit 1
|
127
|
+
end
|
128
|
+
else
|
129
|
+
return ruby_executable
|
130
|
+
end
|
131
|
+
end
|
132
|
+
memoize :ruby_command
|
133
|
+
|
134
|
+
# Returns the full path to the current Ruby interpreter's executable file.
|
135
|
+
# This might not be the actual correct command to use for invoking the Ruby
|
136
|
+
# interpreter; use ruby_command instead.
|
137
|
+
def self.ruby_executable
|
138
|
+
@@ruby_executable ||=
|
139
|
+
rb_config['bindir'] + '/' + rb_config['RUBY_INSTALL_NAME'] + rb_config['EXEEXT']
|
140
|
+
end
|
141
|
+
|
142
|
+
# Returns whether the Ruby interpreter supports process forking.
|
143
|
+
def self.ruby_supports_fork?
|
144
|
+
# MRI >= 1.9.2's respond_to? returns false for methods
|
145
|
+
# that are not implemented.
|
146
|
+
return Process.respond_to?(:fork) &&
|
147
|
+
RUBY_ENGINE != "jruby" &&
|
148
|
+
RUBY_ENGINE != "macruby" &&
|
149
|
+
rb_config['target_os'] !~ /mswin|windows|mingw/
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns whether Phusion Passenger needs Ruby development headers to
|
153
|
+
# be available for the current Ruby implementation.
|
154
|
+
def self.passenger_needs_ruby_dev_header?
|
155
|
+
# Too much of a trouble for JRuby. We can do without it.
|
156
|
+
return RUBY_ENGINE != "jruby"
|
157
|
+
end
|
158
|
+
|
159
|
+
# Returns the correct 'gem' command for this Ruby interpreter.
|
160
|
+
# If `:sudo => true` is given, then the gem command is prefixed by a
|
161
|
+
# sudo command if filesystem permissions require this.
|
162
|
+
def self.gem_command(options = {})
|
163
|
+
command = ruby_tool_command('gem')
|
164
|
+
if options[:sudo] && gem_install_requires_sudo?
|
165
|
+
command = "#{ruby_sudo_command} #{command}"
|
166
|
+
end
|
167
|
+
return command
|
168
|
+
end
|
169
|
+
memoize :gem_command
|
170
|
+
|
171
|
+
# Returns whether running 'gem install' as the current user requires sudo.
|
172
|
+
def self.gem_install_requires_sudo?
|
173
|
+
`#{gem_command} env` =~ /INSTALLATION DIRECTORY: (.+)/
|
174
|
+
if install_dir = $1
|
175
|
+
return !File.writable?(install_dir)
|
176
|
+
else
|
177
|
+
return nil
|
178
|
+
end
|
179
|
+
end
|
180
|
+
memoize :gem_install_requires_sudo?
|
181
|
+
|
182
|
+
# Returns the absolute path to the Rake executable that
|
183
|
+
# belongs to the current Ruby interpreter. Returns nil if it
|
184
|
+
# doesn't exist.
|
185
|
+
#
|
186
|
+
# The return value may not be the actual correct invocation
|
187
|
+
# for Rake. Use `rake_command` for that.
|
188
|
+
def self.rake
|
189
|
+
return locate_ruby_tool('rake')
|
190
|
+
end
|
191
|
+
memoize :rake
|
192
|
+
|
193
|
+
# Returns the correct command string for invoking the Rake executable
|
194
|
+
# that belongs to the current Ruby interpreter. Returns nil if Rake is
|
195
|
+
# not found.
|
196
|
+
def self.rake_command
|
197
|
+
ruby_tool_command('rake')
|
198
|
+
end
|
199
|
+
memoize :rake_command
|
200
|
+
|
201
|
+
# Returns the absolute path to the RSpec runner program that
|
202
|
+
# belongs to the current Ruby interpreter. Returns nil if it
|
203
|
+
# doesn't exist.
|
204
|
+
def self.rspec
|
205
|
+
return locate_ruby_tool('rspec')
|
206
|
+
end
|
207
|
+
memoize :rspec
|
208
|
+
|
209
|
+
# Returns whether the current Ruby interpreter is managed by RVM.
|
210
|
+
def self.in_rvm?
|
211
|
+
bindir = rb_config['bindir']
|
212
|
+
return bindir.include?('/.rvm/') || bindir.include?('/rvm/')
|
213
|
+
end
|
214
|
+
|
215
|
+
# If the current Ruby interpreter is managed by RVM, returns all
|
216
|
+
# directories in which RVM places its working files. This is usually
|
217
|
+
# ~/.rvm or /usr/local/rvm, but in mixed-mode installations there
|
218
|
+
# can be multiple such paths.
|
219
|
+
#
|
220
|
+
# Otherwise returns nil.
|
221
|
+
def self.rvm_paths
|
222
|
+
if in_rvm?
|
223
|
+
result = []
|
224
|
+
[ENV['rvm_path'], "~/.rvm", "/usr/local/rvm"].each do |path|
|
225
|
+
next if path.nil?
|
226
|
+
path = File.expand_path(path)
|
227
|
+
rubies_path = File.join(path, 'rubies')
|
228
|
+
wrappers_path = File.join(path, 'wrappers')
|
229
|
+
gems_path = File.join(path, 'gems')
|
230
|
+
if File.directory?(path) && (File.directory?(rubies_path) ||
|
231
|
+
File.directory?(wrappers_path) || File.directory?(gems_path))
|
232
|
+
result << path
|
233
|
+
end
|
234
|
+
end
|
235
|
+
if result.empty?
|
236
|
+
# Failure to locate the RVM path is probably caused by the
|
237
|
+
# user customizing $rvm_path. Older RVM versions don't
|
238
|
+
# export $rvm_path, making us unable to detect its value.
|
239
|
+
STDERR.puts "Unable to locate the RVM path. Your RVM installation " +
|
240
|
+
"is probably too old. Please update it with " +
|
241
|
+
"'rvm get head && rvm reload && rvm repair all'."
|
242
|
+
exit 1
|
243
|
+
else
|
244
|
+
return result
|
245
|
+
end
|
246
|
+
else
|
247
|
+
return nil
|
248
|
+
end
|
249
|
+
end
|
250
|
+
memoize :rvm_paths
|
251
|
+
|
252
|
+
# If the current Ruby interpreter is managed by RVM, returns the
|
253
|
+
# RVM name which identifies the current Ruby interpreter plus the
|
254
|
+
# currently active gemset, e.g. something like this:
|
255
|
+
# "ruby-1.9.2-p0@mygemset"
|
256
|
+
#
|
257
|
+
# Returns nil otherwise.
|
258
|
+
def self.rvm_ruby_string
|
259
|
+
if in_rvm?
|
260
|
+
# RVM used to export the necessary information through
|
261
|
+
# environment variables, but doesn't always do that anymore
|
262
|
+
# in the latest versions in order to fight env var pollution.
|
263
|
+
# Scanning $LOAD_PATH seems to be the only way to obtain
|
264
|
+
# the information.
|
265
|
+
|
266
|
+
# Getting the RVM name of the Ruby interpreter ("ruby-1.9.2")
|
267
|
+
# isn't so hard, we can extract it from the #ruby_executable
|
268
|
+
# string. Getting the gemset name is a bit harder, so let's
|
269
|
+
# try various strategies...
|
270
|
+
|
271
|
+
# $GEM_HOME usually contains the gem set name.
|
272
|
+
# It may be something like:
|
273
|
+
# /Users/hongli/.rvm/gems/ruby-1.9.3-p392
|
274
|
+
# But also:
|
275
|
+
# /home/bitnami/.rvm/gems/ruby-1.9.3-p385-perf@njist325/ruby/1.9.1
|
276
|
+
if GEM_HOME && GEM_HOME =~ %r{rvm/gems/(.+)}
|
277
|
+
return $1.sub(/\/.*/, '')
|
278
|
+
end
|
279
|
+
|
280
|
+
# User might have explicitly set GEM_HOME to a custom directory,
|
281
|
+
# or might have nuked $GEM_HOME. Extract info from $GEM_PATH.
|
282
|
+
if GEM_PATH
|
283
|
+
GEM_PATH.split(':').each do |gem_path|
|
284
|
+
if gem_path =~ %r{rvm/gems/(.+)}
|
285
|
+
return $1.sub(/\/.*/, '')
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
# That failed too. Try extracting info from from $LOAD_PATH.
|
291
|
+
matching_path = $LOAD_PATH.find_all do |item|
|
292
|
+
item.include?("rvm/gems/")
|
293
|
+
end
|
294
|
+
if matching_path && !matching_path.empty?
|
295
|
+
subpath = matching_path.to_s.gsub(/^.*rvm\/gems\//, '')
|
296
|
+
result = subpath.split('/').first
|
297
|
+
return result if result
|
298
|
+
end
|
299
|
+
|
300
|
+
# On Ruby 1.9, $LOAD_PATH does not contain any gem paths until
|
301
|
+
# at least one gem has been required so the above can fail.
|
302
|
+
# We're out of options now, we can't detect the gem set.
|
303
|
+
# Raise an exception so that the user knows what's going on
|
304
|
+
# instead of having things fail in obscure ways later.
|
305
|
+
STDERR.puts "Unable to autodetect the currently active RVM gem " +
|
306
|
+
"set name. This could happen if you ran this program using 'sudo' " +
|
307
|
+
"instead of 'rvmsudo'. When using RVM, you're always supposed to " +
|
308
|
+
"use 'rvmsudo' instead of 'sudo!'.\n\n" +
|
309
|
+
"Please try rerunning this program using 'rvmsudo'. If that " +
|
310
|
+
"doesn't help, please contact this program's author for support."
|
311
|
+
exit 1
|
312
|
+
end
|
313
|
+
return nil
|
314
|
+
end
|
315
|
+
memoize :rvm_ruby_string
|
316
|
+
|
317
|
+
# Returns the RVM installation mode:
|
318
|
+
# :single - RVM is installed in single-user mode.
|
319
|
+
# :multi - RVM is installed in multi-user mode.
|
320
|
+
# :mixed - RVM is in a mixed-mode installation.
|
321
|
+
# nil - The current Ruby interpreter is not using RVM.
|
322
|
+
def self.rvm_installation_mode
|
323
|
+
if in_rvm?
|
324
|
+
if ENV['rvm_path'] =~ /\.rvm/
|
325
|
+
return :single
|
326
|
+
else
|
327
|
+
if GEM_HOME =~ /\.rvm/
|
328
|
+
return :mixed
|
329
|
+
else
|
330
|
+
return :multi
|
331
|
+
end
|
332
|
+
end
|
333
|
+
else
|
334
|
+
return nil
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
# Returns either 'sudo' or 'rvmsudo' depending on whether the current
|
339
|
+
# Ruby interpreter is managed by RVM.
|
340
|
+
def self.ruby_sudo_command
|
341
|
+
if in_rvm?
|
342
|
+
return "rvmsudo"
|
343
|
+
else
|
344
|
+
return "sudo"
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
# Returns a `sudo` or `rvmsudo` command that spawns a shell, depending
|
349
|
+
# on whether the current Ruby interpreter is managed by RVM.
|
350
|
+
def self.ruby_sudo_shell_command(args = nil)
|
351
|
+
if in_rvm?
|
352
|
+
shell = ENV['SHELL'].to_s
|
353
|
+
if shell.empty?
|
354
|
+
begin
|
355
|
+
user = Etc.getpwuid(0)
|
356
|
+
rescue ArgumentError
|
357
|
+
user = nil
|
358
|
+
end
|
359
|
+
shell = user.shell if user
|
360
|
+
shell = "bash" if !shell || shell.empty?
|
361
|
+
end
|
362
|
+
result = "rvmsudo "
|
363
|
+
result << "#{args} " if args
|
364
|
+
result << shell
|
365
|
+
return result
|
366
|
+
else
|
367
|
+
return "sudo -s #{args}".strip
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
# Locates a Ruby tool, e.g. 'gem', 'rake', 'bundle', etc. Instead of
|
372
|
+
# naively looking in $PATH, this function uses a variety of search heuristics
|
373
|
+
# to find the tool that's really associated with the current Ruby interpreter.
|
374
|
+
# It should never locate a tool that's actually associated with a different
|
375
|
+
# Ruby interpreter.
|
376
|
+
# Returns nil when nothing's found.
|
377
|
+
#
|
378
|
+
# This method only returns the path to the tool script. Running this script
|
379
|
+
# directly does not necessarily mean that it's run under the correct Ruby
|
380
|
+
# interpreter. You may have to prepend it with the Ruby command. Use
|
381
|
+
# `ruby_tool_command` if you want to get a command that you can execute.
|
382
|
+
def self.locate_ruby_tool(name)
|
383
|
+
result = locate_ruby_tool_by_basename(name)
|
384
|
+
if !result
|
385
|
+
exeext = rb_config['EXEEXT']
|
386
|
+
exeext = nil if exeext.empty?
|
387
|
+
if exeext
|
388
|
+
result = locate_ruby_tool_by_basename("#{name}#{exeext}")
|
389
|
+
end
|
390
|
+
if !result
|
391
|
+
result = locate_ruby_tool_by_basename(transform_according_to_ruby_exec_format(name))
|
392
|
+
end
|
393
|
+
if !result && exeext
|
394
|
+
result = locate_ruby_tool_by_basename(transform_according_to_ruby_exec_format(name) + exeext)
|
395
|
+
end
|
396
|
+
end
|
397
|
+
return result
|
398
|
+
end
|
399
|
+
|
400
|
+
# Locates a Ruby tool command, e.g. 'gem', 'rake', 'bundle', etc. Instead of
|
401
|
+
# naively looking in $PATH, this function uses a variety of search heuristics
|
402
|
+
# to find the command that's really associated with the current Ruby interpreter.
|
403
|
+
# It should never locate a command that's actually associated with a different
|
404
|
+
# Ruby interpreter.
|
405
|
+
# Returns nil when nothing's found.
|
406
|
+
#
|
407
|
+
# Unlike `locate_ruby_tool`, which only returns the path to the tool script,
|
408
|
+
# this method returns a full command that you can execute. The returned command
|
409
|
+
# guarantees that the tool is run under the correct Ruby interpreter.
|
410
|
+
def self.ruby_tool_command(name)
|
411
|
+
path = locate_ruby_tool(name)
|
412
|
+
if path
|
413
|
+
if is_ruby_program?(path)
|
414
|
+
"#{ruby_command} #{path}"
|
415
|
+
else
|
416
|
+
# The found tool is a wrapper script, e.g. in RVM's ~/.rvm/wrappers.
|
417
|
+
# In this case, don't include the Ruby command in the result.
|
418
|
+
path
|
419
|
+
end
|
420
|
+
else
|
421
|
+
nil
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
private
|
426
|
+
def self.locate_ruby_tool_by_basename(name)
|
427
|
+
if os_name == "macosx" &&
|
428
|
+
ruby_command =~ %r(\A/System/Library/Frameworks/Ruby.framework/Versions/.*?/usr/bin/ruby\Z)
|
429
|
+
# On OS X we must look for Ruby binaries in /usr/bin.
|
430
|
+
# RubyGems puts executables (e.g. 'rake') in there, not in
|
431
|
+
# /System/Libraries/(...)/bin.
|
432
|
+
filename = "/usr/bin/#{name}"
|
433
|
+
else
|
434
|
+
filename = File.dirname(ruby_command) + "/#{name}"
|
435
|
+
end
|
436
|
+
|
437
|
+
if !File.file?(filename) || !File.executable?(filename)
|
438
|
+
# RubyGems might put binaries in a directory other
|
439
|
+
# than Ruby's bindir. Debian packaged RubyGems and
|
440
|
+
# DebGem packaged RubyGems are the prime examples.
|
441
|
+
begin
|
442
|
+
require 'rubygems' unless defined?(Gem)
|
443
|
+
filename = Gem.bindir + "/#{name}"
|
444
|
+
rescue LoadError
|
445
|
+
filename = nil
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
if !filename || !File.file?(filename) || !File.executable?(filename)
|
450
|
+
# Looks like it's not in the RubyGems bindir. Search in $PATH, but
|
451
|
+
# be very careful about this because whatever we find might belong
|
452
|
+
# to a different Ruby interpreter than the current one.
|
453
|
+
ENV['PATH'].split(':').each do |dir|
|
454
|
+
filename = "#{dir}/#{name}"
|
455
|
+
if File.file?(filename) && File.executable?(filename)
|
456
|
+
shebang = File.open(filename, 'rb') do |f|
|
457
|
+
f.readline.strip
|
458
|
+
end
|
459
|
+
if shebang == "#!#{ruby_command}"
|
460
|
+
# Looks good.
|
461
|
+
break
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
# Not found. Try next path.
|
466
|
+
filename = nil
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
filename
|
471
|
+
end
|
472
|
+
private_class_method :locate_ruby_tool_by_basename
|
473
|
+
|
474
|
+
def self.is_ruby_program?(filename)
|
475
|
+
File.open(filename, 'rb') do |f|
|
476
|
+
return f.readline =~ /ruby/
|
477
|
+
end
|
478
|
+
rescue EOFError
|
479
|
+
return false
|
480
|
+
end
|
481
|
+
private_class_method :is_ruby_program?
|
482
|
+
|
483
|
+
# Deduce Ruby's --program-prefix and --program-suffix from its install name
|
484
|
+
# and transforms the given input name accordingly.
|
485
|
+
#
|
486
|
+
# transform_according_to_ruby_exec_format("rake") => "jrake", "rake1.8", etc
|
487
|
+
def self.transform_according_to_ruby_exec_format(name)
|
488
|
+
install_name = rb_config['RUBY_INSTALL_NAME']
|
489
|
+
if install_name.include?('ruby')
|
490
|
+
format = install_name.sub('ruby', '%s')
|
491
|
+
return sprintf(format, name)
|
492
|
+
else
|
493
|
+
return name
|
494
|
+
end
|
495
|
+
end
|
496
|
+
private_class_method :transform_according_to_ruby_exec_format
|
497
|
+
end
|
478
498
|
|
479
499
|
end # module PhusionPassenger
|