passenger 3.9.2.beta → 4.0.0.rc4
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.
- data/.travis.yml +3 -0
- data/NEWS +77 -7
- data/README.md +3 -11
- data/bin/passenger-install-apache2-module +24 -20
- data/bin/passenger-install-nginx-module +25 -23
- data/build/agents.rb +11 -0
- data/build/apache2.rb +9 -5
- data/build/basics.rb +37 -30
- data/build/common_library.rb +4 -1
- data/build/cplusplus_support.rb +5 -5
- data/build/cxx_tests.rb +28 -8
- data/build/integration_tests.rb +6 -3
- data/build/nginx.rb +3 -3
- data/build/packaging.rb +95 -57
- data/build/ruby_extension.rb +34 -21
- data/build/ruby_tests.rb +4 -2
- data/build/test_basics.rb +1 -1
- data/dev/run_travis.sh +36 -1
- data/doc/Users guide Apache.html +425 -308
- data/doc/Users guide Apache.idmap.txt +78 -70
- data/doc/Users guide Apache.index.sqlite3 +0 -0
- data/doc/Users guide Apache.txt +33 -92
- data/doc/Users guide Nginx.html +519 -220
- data/doc/Users guide Nginx.idmap.txt +78 -60
- data/doc/Users guide Nginx.txt +115 -26
- data/doc/Users guide Standalone.html +8 -2
- data/doc/users_guide_snippets/analysis_and_system_maintenance.txt +1 -7
- data/doc/users_guide_snippets/installation.txt +167 -22
- data/doc/users_guide_snippets/rackup_specifications.txt +4 -0
- data/doc/users_guide_snippets/since_version.txt +1 -0
- data/doc/users_guide_snippets/support_information.txt +3 -7
- data/doc/users_guide_snippets/tips.txt +0 -24
- data/ext/apache2/Configuration.cpp +11 -33
- data/ext/apache2/Configuration.hpp +3 -18
- data/ext/apache2/DirectoryMapper.h +20 -70
- data/ext/apache2/Hooks.cpp +2 -2
- data/ext/common/AgentsStarter.cpp +0 -2
- data/ext/common/AgentsStarter.h +0 -1
- data/ext/common/AgentsStarter.hpp +1 -3
- data/ext/common/ApplicationPool2/AppTypes.cpp +74 -0
- data/ext/common/ApplicationPool2/AppTypes.h +202 -0
- data/ext/common/ApplicationPool2/Common.h +12 -10
- data/ext/common/ApplicationPool2/DirectSpawner.h +256 -0
- data/ext/common/ApplicationPool2/DummySpawner.h +90 -0
- data/ext/common/ApplicationPool2/Group.h +311 -94
- data/ext/common/ApplicationPool2/Implementation.cpp +405 -145
- data/ext/common/ApplicationPool2/Options.h +24 -26
- data/ext/common/ApplicationPool2/PipeWatcher.h +20 -13
- data/ext/common/ApplicationPool2/Pool.h +326 -183
- data/ext/common/ApplicationPool2/Process.h +205 -55
- data/ext/common/ApplicationPool2/README.md +1 -1
- data/ext/common/ApplicationPool2/Session.h +21 -10
- data/ext/common/ApplicationPool2/SmartSpawner.h +801 -0
- data/ext/common/ApplicationPool2/Spawner.h +141 -1149
- data/ext/common/ApplicationPool2/SpawnerFactory.h +132 -0
- data/ext/common/ApplicationPool2/SuperGroup.h +146 -223
- data/ext/common/Constants.h +4 -2
- data/ext/common/Exceptions.h +23 -1
- data/ext/common/Logging.cpp +17 -6
- data/ext/common/Logging.h +37 -7
- data/ext/common/ResourceLocator.h +1 -1
- data/ext/common/Utils.cpp +49 -1
- data/ext/common/Utils.h +13 -4
- data/ext/common/{AnsiColorConstants.h → Utils/AnsiColorConstants.h} +0 -0
- data/ext/common/{BCrypt.cpp → Utils/BCrypt.cpp} +0 -0
- data/ext/common/{BCrypt.h → Utils/BCrypt.h} +0 -0
- data/ext/common/{Blowfish.c → Utils/Blowfish.c} +0 -0
- data/ext/common/{Blowfish.h → Utils/Blowfish.h} +0 -0
- data/ext/common/Utils/CachedFileStat.hpp +27 -25
- data/ext/common/Utils/Curl.h +184 -0
- data/ext/common/{HttpConstants.h → Utils/HttpConstants.h} +3 -0
- data/ext/common/Utils/IOUtils.cpp +6 -2
- data/ext/common/{IniFile.h → Utils/IniFile.h} +0 -0
- data/ext/common/Utils/LargeFiles.cpp +30 -0
- data/ext/common/Utils/LargeFiles.h +40 -0
- data/ext/common/Utils/StrIntUtils.cpp +72 -8
- data/ext/common/Utils/StrIntUtils.h +24 -2
- data/ext/common/Utils/StringMap.h +12 -2
- data/ext/common/Utils/VariantMap.h +51 -2
- data/ext/common/Utils/jsoncpp.cpp +1 -1
- data/ext/common/agents/Base.cpp +147 -11
- data/ext/common/agents/HelperAgent/AgentOptions.h +14 -6
- data/ext/common/agents/HelperAgent/Main.cpp +79 -19
- data/ext/common/agents/HelperAgent/RequestHandler.h +36 -16
- data/ext/common/agents/LoggingAgent/LoggingServer.h +3 -5
- data/ext/common/agents/LoggingAgent/Main.cpp +2 -4
- data/ext/common/agents/LoggingAgent/RemoteSender.h +18 -24
- data/ext/common/agents/SpawnPreparer.cpp +7 -0
- data/ext/common/agents/Watchdog/Main.cpp +96 -38
- data/ext/nginx/Configuration.c +26 -22
- data/ext/nginx/Configuration.h +4 -2
- data/ext/nginx/ContentHandler.c +23 -52
- data/ext/nginx/ContentHandler.h +5 -11
- data/ext/nginx/config +10 -3
- data/ext/nginx/ngx_http_passenger_module.c +21 -6
- data/ext/nginx/ngx_http_passenger_module.h +4 -1
- data/ext/oxt/dynamic_thread_group.hpp +9 -1
- data/ext/oxt/system_calls.cpp +2 -2
- data/ext/ruby/extconf.rb +2 -1
- data/helper-scripts/backtrace-sanitizer.rb +2 -0
- data/helper-scripts/wsgi-loader.py +54 -21
- data/lib/phusion_passenger.rb +5 -3
- data/lib/phusion_passenger/abstract_installer.rb +18 -41
- data/lib/phusion_passenger/admin_tools/memory_stats.rb +2 -2
- data/lib/phusion_passenger/admin_tools/server_instance.rb +2 -2
- data/lib/phusion_passenger/common_library.rb +23 -3
- data/lib/phusion_passenger/debug_logging.rb +10 -3
- data/lib/phusion_passenger/packaging.rb +1 -0
- data/lib/phusion_passenger/platform_info.rb +113 -115
- data/lib/phusion_passenger/platform_info/compiler.rb +224 -134
- data/lib/phusion_passenger/platform_info/cxx_portability.rb +143 -0
- data/lib/phusion_passenger/platform_info/depcheck.rb +371 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/apache2.rb +124 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/compiler_toolchain.rb +97 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/gems.rb +39 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/libs.rb +118 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/ruby.rb +137 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/utilities.rb +15 -0
- data/lib/phusion_passenger/platform_info/operating_system.rb +6 -5
- data/lib/phusion_passenger/platform_info/ruby.rb +45 -34
- data/lib/phusion_passenger/request_handler.rb +35 -22
- data/lib/phusion_passenger/request_handler/thread_handler.rb +5 -6
- data/lib/phusion_passenger/ruby_core_enhancements.rb +7 -1
- data/lib/phusion_passenger/standalone/runtime_installer.rb +43 -34
- data/lib/phusion_passenger/utils/robust_interruption.rb +34 -18
- data/passenger.gemspec +25 -0
- data/resources/templates/standalone/config.erb +3 -1
- data/test/config.json.travis +2 -2
- data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +37 -5
- data/test/cxx/ApplicationPool2/PoolTest.cpp +143 -50
- data/test/cxx/ApplicationPool2/ProcessTest.cpp +8 -0
- data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +28 -17
- data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +31 -26
- data/test/cxx/RequestHandlerTest.cpp +17 -1
- data/test/cxx/UtilsTest.cpp +84 -10
- data/test/integration_tests/apache2_tests.rb +49 -163
- data/test/integration_tests/hello_world_wsgi_spec.rb +2 -2
- data/test/integration_tests/mycook_spec.rb +1 -1
- data/test/integration_tests/nginx_tests.rb +37 -19
- data/test/ruby/request_handler_spec.rb +1 -0
- data/test/ruby/spec_helper.rb +52 -1
- data/test/stub/nginx/nginx.conf.erb +2 -0
- data/test/stub/rack/start.rb +5 -0
- data/test/stub/rails3.0/Gemfile.lock +30 -30
- data/test/stub/rails3.1/Gemfile +1 -1
- data/test/stub/rails3.1/Gemfile.lock +3 -3
- data/test/stub/rails3.2/Gemfile +1 -1
- data/test/stub/rails3.2/Gemfile.lock +4 -4
- data/test/stub/rails_apps/2.3/mycook/app/controllers/welcome_controller.rb +1 -1
- data/test/stub/rails_apps/2.3/mycook/app/helpers/recipes_helper.rb +2 -0
- data/test/stub/rails_apps/2.3/mycook/app/helpers/test_helper.rb +2 -0
- data/test/stub/rails_apps/2.3/mycook/app/helpers/uploads_helper.rb +2 -0
- data/test/stub/rails_apps/2.3/mycook/app/helpers/welcome_helper.rb +2 -0
- data/test/support/nginx_controller.rb +2 -1
- metadata +160 -156
- data/build/gempackagetask.rb +0 -99
- data/build/packagetask.rb +0 -186
- data/ext/common/StringListCreator.h +0 -83
- data/lib/phusion_passenger/dependencies.rb +0 -657
data/lib/phusion_passenger.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
# Copyright (c) 2010
|
3
|
+
# Copyright (c) 2010-2013 Phusion
|
4
4
|
#
|
5
5
|
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
6
|
#
|
@@ -28,10 +28,12 @@ module PhusionPassenger
|
|
28
28
|
|
29
29
|
###### Version numbers ######
|
30
30
|
|
31
|
+
PACKAGE_NAME = 'passenger'
|
32
|
+
|
31
33
|
# Phusion Passenger version number. Don't forget to edit ext/common/Constants.h too.
|
32
|
-
VERSION_STRING = '
|
34
|
+
VERSION_STRING = '4.0.0.rc4'
|
33
35
|
|
34
|
-
PREFERRED_NGINX_VERSION = '1.2.
|
36
|
+
PREFERRED_NGINX_VERSION = '1.2.7'
|
35
37
|
PREFERRED_PCRE_VERSION = '8.31'
|
36
38
|
STANDALONE_INTERFACE_VERSION = 1
|
37
39
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
-
# Copyright (c) 2010 Phusion
|
2
|
+
# Copyright (c) 2010-2013 Phusion
|
3
3
|
#
|
4
4
|
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
5
5
|
#
|
@@ -106,30 +106,26 @@ protected
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def dependencies
|
109
|
-
return []
|
109
|
+
return [[], []]
|
110
110
|
end
|
111
111
|
|
112
112
|
def check_dependencies(show_new_screen = true)
|
113
113
|
new_screen if show_new_screen
|
114
|
-
missing_dependencies = []
|
115
114
|
puts "<banner>Checking for required software...</banner>"
|
116
115
|
puts
|
117
|
-
dependencies.each do |dep|
|
118
|
-
print " * #{dep.name}... "
|
119
|
-
result = dep.check
|
120
|
-
if result.found?
|
121
|
-
if result.found_at
|
122
|
-
puts "<green>found at #{result.found_at}</green>"
|
123
|
-
else
|
124
|
-
puts "<green>found</green>"
|
125
|
-
end
|
126
|
-
else
|
127
|
-
puts "<red>not found</red>"
|
128
|
-
missing_dependencies << dep
|
129
|
-
end
|
130
|
-
end
|
131
116
|
|
132
|
-
|
117
|
+
require 'phusion_passenger/platform_info/depcheck'
|
118
|
+
specs, ids = dependencies
|
119
|
+
runner = PlatformInfo::Depcheck::ConsoleRunner.new
|
120
|
+
|
121
|
+
specs.each do |spec|
|
122
|
+
PlatformInfo::Depcheck.load(spec)
|
123
|
+
end
|
124
|
+
ids.each do |id|
|
125
|
+
runner.add(id)
|
126
|
+
end
|
127
|
+
|
128
|
+
if runner.check_all
|
133
129
|
return true
|
134
130
|
else
|
135
131
|
puts
|
@@ -141,13 +137,14 @@ protected
|
|
141
137
|
else
|
142
138
|
wait(10)
|
143
139
|
end
|
144
|
-
|
140
|
+
|
145
141
|
line
|
146
142
|
puts
|
147
143
|
puts "<banner>Installation instructions for required software</banner>"
|
148
144
|
puts
|
149
|
-
missing_dependencies.each do |dep|
|
150
|
-
|
145
|
+
runner.missing_dependencies.each do |dep|
|
146
|
+
puts " * To install <yellow>#{dep.name}</yellow>:"
|
147
|
+
puts " #{dep.install_instructions}"
|
151
148
|
puts
|
152
149
|
end
|
153
150
|
if respond_to?(:users_guide)
|
@@ -310,26 +307,6 @@ protected
|
|
310
307
|
return sh("curl", url, "-f", "-L", "-o", output)
|
311
308
|
end
|
312
309
|
end
|
313
|
-
|
314
|
-
private
|
315
|
-
def print_dependency_installation_instructions(dep)
|
316
|
-
puts " * To install <yellow>#{dep.name}</yellow>:"
|
317
|
-
if dep.install_comments
|
318
|
-
puts " " << dep.install_comments
|
319
|
-
end
|
320
|
-
if !dep.install_command.nil?
|
321
|
-
puts " Please run <b>#{dep.install_command}</b> as root."
|
322
|
-
elsif !dep.install_instructions.nil?
|
323
|
-
puts " " << dep.install_instructions
|
324
|
-
elsif !dep.website.nil?
|
325
|
-
puts " Please download it from <b>#{dep.website}</b>"
|
326
|
-
if !dep.website_comments.nil?
|
327
|
-
puts " (#{dep.website_comments})"
|
328
|
-
end
|
329
|
-
else
|
330
|
-
puts " Search Google."
|
331
|
-
end
|
332
|
-
end
|
333
310
|
end
|
334
311
|
|
335
312
|
end # module PhusionPassenger
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
-
# Copyright (c) 2010 Phusion
|
2
|
+
# Copyright (c) 2010-2013 Phusion
|
3
3
|
#
|
4
4
|
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
5
5
|
#
|
@@ -87,7 +87,7 @@ class MemoryStats
|
|
87
87
|
# Phusion Passenger is not running.
|
88
88
|
def passenger_processes
|
89
89
|
@passenger_processes ||= list_processes(:match =>
|
90
|
-
/((^| )Passenger |(^| )Rails:|(^| )Rack:|PassengerHelperAgent|PassengerWatchdog|PassengerLoggingAgent)/)
|
90
|
+
/((^| )Passenger |(^| )Rails:|(^| )Rack:|PassengerHelperAgent|PassengerWatchdog|PassengerLoggingAgent|wsgi-loader.py)/)
|
91
91
|
end
|
92
92
|
|
93
93
|
# Returns the sum of the memory usages of all given processes.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
-
# Copyright (c) 2010 Phusion
|
2
|
+
# Copyright (c) 2010-2013 Phusion
|
3
3
|
#
|
4
4
|
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
5
5
|
#
|
@@ -276,7 +276,7 @@ class ServerInstance
|
|
276
276
|
doc = REXML::Document.new(xml)
|
277
277
|
|
278
278
|
groups = []
|
279
|
-
doc.elements.each("info/supergroups/group") do |group_xml|
|
279
|
+
doc.elements.each("info/supergroups/supergroup/group") do |group_xml|
|
280
280
|
group = Group.new(group_xml.elements["app_root"].text,
|
281
281
|
group_xml.elements["name"].text,
|
282
282
|
group_xml.elements["environment"].text,
|
@@ -361,6 +361,12 @@ COMMON_LIBRARY = CommonLibraryBuilder.new do
|
|
361
361
|
Utils/CachedFileStat.h
|
362
362
|
Utils/CachedFileStat.hpp
|
363
363
|
)
|
364
|
+
define_component 'Utils/LargeFiles.o',
|
365
|
+
:source => 'Utils/LargeFiles.cpp',
|
366
|
+
:category => :other,
|
367
|
+
:deps => %w(
|
368
|
+
Utils/LargeFiles.h
|
369
|
+
)
|
364
370
|
define_component 'ApplicationPool2/Implementation.o',
|
365
371
|
:source => 'ApplicationPool2/Implementation.cpp',
|
366
372
|
:category => :other,
|
@@ -373,6 +379,20 @@ COMMON_LIBRARY = CommonLibraryBuilder.new do
|
|
373
379
|
ApplicationPool2/Session.h
|
374
380
|
ApplicationPool2/Options.h
|
375
381
|
ApplicationPool2/PipeWatcher.h
|
382
|
+
ApplicationPool2/AppTypes.h
|
383
|
+
ApplicationPool2/Spawner.h
|
384
|
+
ApplicationPool2/SpawnerFactory.h
|
385
|
+
ApplicationPool2/SmartSpawner.h
|
386
|
+
ApplicationPool2/DirectSpawner.h
|
387
|
+
ApplicationPool2/DummySpawner.h
|
388
|
+
)
|
389
|
+
define_component 'ApplicationPool2/AppTypes.o',
|
390
|
+
:source => 'ApplicationPool2/AppTypes.cpp',
|
391
|
+
:category => :other,
|
392
|
+
:deps => %w(
|
393
|
+
ApplicationPool2/AppTypes.h
|
394
|
+
Utils/StrIntUtils.h
|
395
|
+
Utils/CachedFileStat.h
|
376
396
|
)
|
377
397
|
define_component 'AccountsDatabase.o',
|
378
398
|
:source => 'AccountsDatabase.cpp',
|
@@ -389,10 +409,10 @@ COMMON_LIBRARY = CommonLibraryBuilder.new do
|
|
389
409
|
:deps => %w(
|
390
410
|
AgentsStarter.h
|
391
411
|
AgentsStarter.hpp
|
392
|
-
IniFile.h
|
393
412
|
ResourceLocator.h
|
394
413
|
MessageClient.h
|
395
414
|
ServerInstanceDir.h
|
415
|
+
Utils/IniFile.h
|
396
416
|
Utils/VariantMap.h
|
397
417
|
)
|
398
418
|
define_component 'AgentsBase.o',
|
@@ -437,5 +457,5 @@ COMMON_LIBRARY = CommonLibraryBuilder.new do
|
|
437
457
|
end
|
438
458
|
|
439
459
|
# Objects that must be linked into the Nginx binary.
|
440
|
-
NGINX_LIBS_SELECTOR = [:base, 'AgentsStarter.o', '
|
441
|
-
'Utils/Base64.o', 'agents/LoggingAgent/FilterSupport.o']
|
460
|
+
NGINX_LIBS_SELECTOR = [:base, 'AgentsStarter.o', 'ApplicationPool2/AppTypes.o',
|
461
|
+
'Utils/CachedFileStat.o', 'Utils/Base64.o', 'agents/LoggingAgent/FilterSupport.o']
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
-
# Copyright (c) 2010 Phusion
|
2
|
+
# Copyright (c) 2010-2013 Phusion
|
3
3
|
#
|
4
4
|
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
5
5
|
#
|
@@ -98,10 +98,17 @@ module DebugLogging
|
|
98
98
|
now = Time.now
|
99
99
|
time_str = now.strftime("%Y-%m-%d %H:%M:%S.")
|
100
100
|
time_str << sprintf("%04d", now.usec / 100)
|
101
|
-
|
101
|
+
|
102
|
+
current_thread = Thread.current
|
103
|
+
if !(thread_id = current_thread[:id])
|
104
|
+
current_thread.to_s =~ /:(0x[0-9a-f]+)/i
|
105
|
+
thread_id = current_thread[:id] = $1 || '?'
|
106
|
+
end
|
107
|
+
if thread_name = current_thread[:name]
|
102
108
|
thread_name = "(#{thread_name})"
|
103
109
|
end
|
104
|
-
|
110
|
+
|
111
|
+
output.write("[ #{time_str} #{$$}/#{thread_id}#{thread_name} #{location} ]: #{message}\n")
|
105
112
|
output.flush
|
106
113
|
end
|
107
114
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
-
# Copyright (c) 2010 Phusion
|
2
|
+
# Copyright (c) 2010-2013 Phusion
|
3
3
|
#
|
4
4
|
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
5
5
|
#
|
@@ -28,9 +28,11 @@ module PhusionPassenger
|
|
28
28
|
module PlatformInfo
|
29
29
|
private
|
30
30
|
@@cache_dir = nil
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
@@verbose = ['1', 'true', 'on', 'yes'].include?(ENV['VERBOSE'])
|
32
|
+
@@log_implementation = lambda do |message|
|
33
|
+
message = reindent(message, 3)
|
34
|
+
message.sub!(/^ /, '')
|
35
|
+
STDERR.puts " * #{message}"
|
34
36
|
end
|
35
37
|
|
36
38
|
def self.private_class_method(name)
|
@@ -128,37 +130,98 @@ private
|
|
128
130
|
return nil
|
129
131
|
end
|
130
132
|
private_class_method :select_executable
|
131
|
-
|
132
|
-
def self.
|
133
|
-
|
134
|
-
|
135
|
-
|
133
|
+
|
134
|
+
def self.unindent(str)
|
135
|
+
str = str.dup
|
136
|
+
str.gsub!(/\A([\s\t]*\n)+/, '')
|
137
|
+
str.gsub!(/[\s\t\n]+\Z/, '')
|
138
|
+
indent = str.split("\n").select{ |line| !line.strip.empty? }.map{ |line| line.index(/[^\s]/) }.compact.min || 0
|
139
|
+
str.gsub!(/^[[:blank:]]{#{indent}}/, '')
|
140
|
+
return str
|
141
|
+
end
|
142
|
+
private_class_method :unindent
|
143
|
+
|
144
|
+
def self.reindent(str, level)
|
145
|
+
str = unindent(str)
|
146
|
+
str.gsub!(/^/, ' ' * level)
|
147
|
+
return str
|
136
148
|
end
|
137
|
-
private_class_method :
|
149
|
+
private_class_method :reindent
|
150
|
+
|
151
|
+
def self.create_temp_file(name, dir = tmpdir)
|
152
|
+
tag = "#{Process.pid}.#{Thread.current.object_id.to_s(16)}"
|
153
|
+
if name =~ /\./
|
154
|
+
ext = File.extname(name)
|
155
|
+
name = File.basename(name, ext) + "-#{tag}#{ext}"
|
156
|
+
else
|
157
|
+
name = "#{name}-#{tag}"
|
158
|
+
end
|
159
|
+
filename = "#{dir}/#{name}"
|
160
|
+
f = File.open(filename, "w")
|
161
|
+
begin
|
162
|
+
yield(filename, f)
|
163
|
+
ensure
|
164
|
+
f.close if !f.closed?
|
165
|
+
File.unlink(filename) if File.exist?(filename)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
private_class_method :create_temp_file
|
169
|
+
|
170
|
+
def self.log(message)
|
171
|
+
if verbose?
|
172
|
+
@@log_implementation.call(message)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
private_class_method :log
|
138
176
|
|
139
177
|
public
|
140
178
|
class RuntimeError < ::RuntimeError
|
141
179
|
end
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
# This function exists because system('which') doesn't always behave
|
147
|
-
# correctly, for some weird reason.
|
148
|
-
def self.find_command(name)
|
149
|
-
name = name.to_s
|
150
|
-
ENV['PATH'].to_s.split(File::PATH_SEPARATOR).detect do |directory|
|
151
|
-
path = File.join(directory, name)
|
152
|
-
if File.file?(path) && File.executable?(path)
|
153
|
-
return path
|
154
|
-
end
|
155
|
-
end
|
156
|
-
return nil
|
180
|
+
|
181
|
+
|
182
|
+
def self.cache_dir=(value)
|
183
|
+
@@cache_dir = value
|
157
184
|
end
|
158
|
-
|
185
|
+
|
186
|
+
def self.cache_dir
|
187
|
+
return @@cache_dir
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.verbose=(val)
|
191
|
+
@@verbose = val
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.verbose?
|
195
|
+
return @@verbose
|
196
|
+
end
|
197
|
+
|
198
|
+
def self.log_implementation=(impl)
|
199
|
+
@@log_implementation = impl
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.log_implementation
|
203
|
+
return @@log_implementation
|
204
|
+
end
|
205
|
+
|
206
|
+
|
159
207
|
def self.env_defined?(name)
|
160
208
|
return !ENV[name].nil? && !ENV[name].empty?
|
161
209
|
end
|
210
|
+
|
211
|
+
def self.string_env(name, default_value = nil)
|
212
|
+
value = ENV[name]
|
213
|
+
if value.nil? || value.empty?
|
214
|
+
return default_value
|
215
|
+
else
|
216
|
+
return value
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.read_file(filename)
|
221
|
+
return File.read(filename)
|
222
|
+
rescue
|
223
|
+
return ""
|
224
|
+
end
|
162
225
|
|
163
226
|
def self.tmpdir
|
164
227
|
result = ENV['TMPDIR']
|
@@ -246,94 +309,6 @@ public
|
|
246
309
|
raise RuntimeError, message
|
247
310
|
end
|
248
311
|
memoize :tmpexedir
|
249
|
-
|
250
|
-
def self.cc
|
251
|
-
return ENV['CC'] || "gcc"
|
252
|
-
end
|
253
|
-
|
254
|
-
def self.cxx
|
255
|
-
return ENV['CXX'] || "g++"
|
256
|
-
end
|
257
|
-
|
258
|
-
def self.try_compile(language, source, flags = nil)
|
259
|
-
if language == :c
|
260
|
-
compiler = cc
|
261
|
-
elsif language == :cxx
|
262
|
-
compiler = cxx
|
263
|
-
else
|
264
|
-
raise ArgumentError,"Unsupported language '#{language}'"
|
265
|
-
end
|
266
|
-
filename = File.join("#{tmpexedir}/passenger-compile-check-#{Process.pid}.c")
|
267
|
-
File.open(filename, "w") do |f|
|
268
|
-
f.puts(source)
|
269
|
-
end
|
270
|
-
begin
|
271
|
-
return system("(#{compiler} #{flags} -c '#{filename}' -o '#{filename}.o') >/dev/null 2>/dev/null")
|
272
|
-
ensure
|
273
|
-
File.unlink(filename) rescue nil
|
274
|
-
File.unlink("#{filename}.o") rescue nil
|
275
|
-
end
|
276
|
-
end
|
277
|
-
private_class_method :try_compile
|
278
|
-
|
279
|
-
def self.try_link(language, source, flags = nil)
|
280
|
-
if language == :c
|
281
|
-
compiler = cc
|
282
|
-
elsif language == :cxx
|
283
|
-
compiler = cxx
|
284
|
-
else
|
285
|
-
raise ArgumentError,"Unsupported language '#{language}'"
|
286
|
-
end
|
287
|
-
filename = File.join("#{tmpexedir}/passenger-link-check-#{Process.pid}.c")
|
288
|
-
File.open(filename, "w") do |f|
|
289
|
-
f.puts(source)
|
290
|
-
end
|
291
|
-
begin
|
292
|
-
return system("(#{compiler} #{flags} '#{filename}' -o '#{filename}.out') >/dev/null 2>/dev/null")
|
293
|
-
ensure
|
294
|
-
File.unlink(filename) rescue nil
|
295
|
-
File.unlink("#{filename}.out") rescue nil
|
296
|
-
end
|
297
|
-
end
|
298
|
-
private_class_method :try_link
|
299
|
-
|
300
|
-
def self.try_compile_and_run(language, source, flags = nil)
|
301
|
-
if language == :c
|
302
|
-
compiler = cc
|
303
|
-
elsif language == :cxx
|
304
|
-
compiler = cxx
|
305
|
-
else
|
306
|
-
raise ArgumentError,"Unsupported language '#{language}'"
|
307
|
-
end
|
308
|
-
filename = File.join("#{tmpexedir}/passenger-compile-check-#{Process.pid}.c")
|
309
|
-
File.open(filename, "w") do |f|
|
310
|
-
f.puts(source)
|
311
|
-
end
|
312
|
-
begin
|
313
|
-
if system("(#{compiler} #{flags} '#{filename}' -o '#{filename}.out') >/dev/null 2>/dev/null")
|
314
|
-
if Process.respond_to?(:spawn)
|
315
|
-
pid = Process.spawn("#{filename}.out",
|
316
|
-
:out => ["/dev/null", "w"],
|
317
|
-
:err => ["/dev/null", "w"])
|
318
|
-
|
319
|
-
else
|
320
|
-
pid = fork do
|
321
|
-
STDOUT.reopen("/dev/null", "w")
|
322
|
-
STDERR.reopen("/dev/null", "w")
|
323
|
-
exec("#{filename}.out")
|
324
|
-
end
|
325
|
-
end
|
326
|
-
pid = Process.waitpid(pid) rescue nil
|
327
|
-
return pid && $?.exitstatus == 0
|
328
|
-
else
|
329
|
-
return false
|
330
|
-
end
|
331
|
-
ensure
|
332
|
-
File.unlink(filename) rescue nil
|
333
|
-
File.unlink("#{filename}.out") rescue nil
|
334
|
-
end
|
335
|
-
end
|
336
|
-
private_class_method :try_compile_and_run
|
337
312
|
|
338
313
|
def self.rb_config
|
339
314
|
if defined?(::RbConfig)
|
@@ -342,7 +317,30 @@ public
|
|
342
317
|
return ::Config::CONFIG
|
343
318
|
end
|
344
319
|
end
|
345
|
-
|
320
|
+
|
321
|
+
# Check whether the specified command is in $PATH, and return its
|
322
|
+
# absolute filename. Returns nil if the command is not found.
|
323
|
+
#
|
324
|
+
# This function exists because system('which') doesn't always behave
|
325
|
+
# correctly, for some weird reason.
|
326
|
+
def self.find_command(name)
|
327
|
+
name = name.to_s
|
328
|
+
if name =~ /^\//
|
329
|
+
if File.executable?(name)
|
330
|
+
return name
|
331
|
+
else
|
332
|
+
return nil
|
333
|
+
end
|
334
|
+
else
|
335
|
+
ENV['PATH'].to_s.split(File::PATH_SEPARATOR).detect do |directory|
|
336
|
+
path = File.join(directory, name)
|
337
|
+
if File.file?(path) && File.executable?(path)
|
338
|
+
return path
|
339
|
+
end
|
340
|
+
end
|
341
|
+
return nil
|
342
|
+
end
|
343
|
+
end
|
346
344
|
end
|
347
345
|
|
348
346
|
end # module PhusionPassenger
|