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
@@ -26,7 +26,7 @@
|
|
26
26
|
source_root = File.expand_path("..", File.dirname(__FILE__))
|
27
27
|
$LOAD_PATH.unshift("#{source_root}/lib")
|
28
28
|
begin
|
29
|
-
|
29
|
+
require 'rubygems'
|
30
30
|
rescue LoadError
|
31
31
|
end
|
32
32
|
require 'phusion_passenger'
|
@@ -43,613 +43,613 @@ PhusionPassenger.require_passenger_lib 'utils/terminal_choice_menu'
|
|
43
43
|
PhusionPassenger.require_passenger_lib 'utils/tmpio'
|
44
44
|
|
45
45
|
DOWNLOAD_OPTION = {
|
46
|
-
|
47
|
-
|
46
|
+
:connect_timeout => 30,
|
47
|
+
:idle_timeout => 30
|
48
48
|
}
|
49
49
|
|
50
50
|
class Installer < PhusionPassenger::AbstractInstaller
|
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
|
-
|
51
|
+
include PhusionPassenger
|
52
|
+
TerminalChoiceMenu = PhusionPassenger::Utils::TerminalChoiceMenu
|
53
|
+
|
54
|
+
def dependencies
|
55
|
+
specs = [
|
56
|
+
'depcheck_specs/compiler_toolchain',
|
57
|
+
'depcheck_specs/ruby',
|
58
|
+
'depcheck_specs/gems',
|
59
|
+
'depcheck_specs/libs',
|
60
|
+
'depcheck_specs/utilities'
|
61
|
+
]
|
62
|
+
ids = [
|
63
|
+
'cc',
|
64
|
+
'c++',
|
65
|
+
'download-tool',
|
66
|
+
'libcurl-dev',
|
67
|
+
'openssl-dev',
|
68
|
+
'zlib-dev',
|
69
|
+
'rake',
|
70
|
+
'ruby-openssl',
|
71
|
+
'rubygems'
|
72
|
+
]
|
73
|
+
if @languages.include?("ruby")
|
74
|
+
if PlatformInfo.passenger_needs_ruby_dev_header?
|
75
|
+
ids << 'ruby-dev'
|
76
|
+
end
|
77
|
+
ids << 'rack'
|
78
|
+
end
|
79
|
+
return [specs, ids]
|
80
|
+
end
|
81
|
+
|
82
|
+
def users_guide_path
|
83
|
+
return PhusionPassenger.nginx_doc_path
|
84
|
+
end
|
85
|
+
|
86
|
+
def users_guide_url
|
87
|
+
return NGINX_DOC_URL
|
88
|
+
end
|
89
|
+
|
90
|
+
def run_steps
|
91
|
+
# Make sure the configure script finds the correct
|
92
|
+
# passenger-config command.
|
93
|
+
ENV['PATH'] = PhusionPassenger.bin_dir + ":" + ENV['PATH']
|
94
|
+
|
95
|
+
show_welcome_screen
|
96
|
+
query_interested_languages
|
97
|
+
check_gem_install_permission_problems || exit(1)
|
98
|
+
check_directory_accessible_by_web_server
|
99
|
+
check_nginx_module_sources_available || exit(1)
|
100
|
+
check_dependencies || exit(1)
|
101
|
+
if needs_compiling_support_files?
|
102
|
+
check_whether_we_can_write_to(PhusionPassenger.build_system_dir) || exit(1)
|
103
|
+
end
|
104
|
+
check_whether_os_is_broken
|
105
|
+
check_whether_system_has_enough_ram
|
106
|
+
|
107
|
+
download_and_install = should_we_download_and_install_nginx_automatically?
|
108
|
+
if pcre_is_installed?
|
109
|
+
@pcre_source_dir = nil
|
110
|
+
else
|
111
|
+
@pcre_source_dir = download_and_extract_pcre
|
112
|
+
end
|
113
|
+
if download_and_install
|
114
|
+
nginx_source_dir = download_and_extract_nginx
|
115
|
+
if nginx_source_dir.nil?
|
116
|
+
show_possible_solutions_for_download_and_extraction_problems
|
117
|
+
exit(1)
|
118
|
+
end
|
119
|
+
nginx_prefix = ask_for_nginx_install_prefix
|
120
|
+
check_whether_other_nginx_installations_exist(nginx_prefix)
|
121
|
+
if @extra_configure_flags == "none"
|
122
|
+
extra_nginx_configure_flags = nil
|
123
|
+
else
|
124
|
+
extra_nginx_configure_flags = @extra_configure_flags
|
125
|
+
end
|
126
|
+
else
|
127
|
+
nginx_source_dir = ask_for_nginx_source_dir
|
128
|
+
nginx_prefix = ask_for_nginx_install_prefix
|
129
|
+
check_whether_other_nginx_installations_exist(nginx_prefix)
|
130
|
+
extra_nginx_configure_flags = ask_for_extra_nginx_configure_flags(nginx_prefix)
|
131
|
+
end
|
132
|
+
check_whether_we_can_write_to(nginx_prefix) || exit(1)
|
133
|
+
nginx_config_already_exists_before_installing = nginx_config_exists?(nginx_prefix)
|
134
|
+
if needs_compiling_support_files?
|
135
|
+
if !compile_passenger_support_files
|
136
|
+
show_possible_solutions_for_compilation_and_installation_problems
|
137
|
+
exit(1)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
if install_nginx(nginx_source_dir, nginx_prefix, extra_nginx_configure_flags)
|
141
|
+
if nginx_config_already_exists_before_installing || !locate_nginx_config_file(nginx_prefix)
|
142
|
+
show_passenger_config_snippets(nginx_prefix)
|
143
|
+
else
|
144
|
+
insert_passenger_config_snippets(nginx_prefix)
|
145
|
+
end
|
146
|
+
show_deployment_example
|
147
|
+
else
|
148
|
+
show_possible_solutions_for_compilation_and_installation_problems
|
149
|
+
exit(1)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def before_install
|
154
|
+
super
|
155
|
+
myself = `whoami`.strip
|
156
|
+
@working_dir = PhusionPassenger::Utils.mktmpdir("passenger.", PlatformInfo.tmpexedir)
|
157
|
+
end
|
158
|
+
|
159
|
+
def after_install
|
160
|
+
super
|
161
|
+
FileUtils.remove_entry_secure(@working_dir) if @working_dir
|
162
|
+
end
|
163
163
|
|
164
164
|
private
|
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
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
165
|
+
def show_welcome_screen
|
166
|
+
render_template 'nginx/welcome', :version => VERSION_STRING
|
167
|
+
wait
|
168
|
+
end
|
169
|
+
|
170
|
+
def query_interested_languages
|
171
|
+
menu = TerminalChoiceMenu.new(["Ruby", "Python", "Node.js", "Meteor"])
|
172
|
+
menu["Ruby"].checked = interesting_language?('ruby')
|
173
|
+
menu["Python"].checked = interesting_language?('python')
|
174
|
+
menu["Node.js"].checked = interesting_language?('nodejs', 'node')
|
175
|
+
menu["Meteor"].checked = interesting_language?('meteor')
|
176
|
+
|
177
|
+
new_screen
|
178
|
+
puts "<banner>Which languages are you interested in?</banner>"
|
179
|
+
puts
|
180
|
+
if interactive?
|
181
|
+
puts "Use <space> to select."
|
182
|
+
puts "<dgray>If the menu doesn't display correctly, press '!'</dgray>"
|
183
|
+
else
|
184
|
+
puts "Override selection with --languages."
|
185
|
+
end
|
186
|
+
puts
|
187
|
+
|
188
|
+
if interactive?
|
189
|
+
begin
|
190
|
+
menu.query
|
191
|
+
rescue Interrupt
|
192
|
+
raise Abort
|
193
|
+
end
|
194
|
+
else
|
195
|
+
menu.display_choices
|
196
|
+
puts
|
197
|
+
end
|
198
|
+
|
199
|
+
@languages = menu.selected_choices.map{ |x| x.downcase.gsub(/\./, '') }
|
200
|
+
end
|
201
|
+
|
202
|
+
def interesting_language?(name, command = nil)
|
203
|
+
if @languages
|
204
|
+
return @languages.include?(name)
|
205
|
+
else
|
206
|
+
return !!PlatformInfo.find_command(command || name)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def check_nginx_module_sources_available
|
211
|
+
if PhusionPassenger.custom_packaged? &&
|
212
|
+
(!PhusionPassenger.nginx_module_source_dir || !File.exist?(PhusionPassenger.nginx_module_source_dir))
|
213
|
+
new_screen
|
214
|
+
render_template 'nginx/nginx_module_sources_not_available'
|
215
|
+
return false
|
216
|
+
else
|
217
|
+
return true
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def needs_compiling_support_files?
|
222
|
+
return !PhusionPassenger.build_system_dir.nil?
|
223
|
+
end
|
224
|
+
|
225
|
+
def compile_passenger_support_files
|
226
|
+
new_screen
|
227
|
+
puts "<banner>Compiling Passenger support files...</banner>"
|
228
|
+
Dir.chdir(PhusionPassenger.build_system_dir) do
|
229
|
+
return sh("env NOEXEC_DISABLE=1 #{PlatformInfo.rake_command} nginx:clean nginx RELEASE=yes")
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def should_we_download_and_install_nginx_automatically?
|
234
|
+
new_screen
|
235
|
+
render_template 'nginx/query_download_and_install',
|
236
|
+
:nginx_version => PREFERRED_NGINX_VERSION
|
237
|
+
puts
|
238
|
+
|
239
|
+
if @auto_download
|
240
|
+
puts "<b>=> Proceeding with choice 1.</b>"
|
241
|
+
return true
|
242
|
+
elsif @nginx_source_dir
|
243
|
+
puts "<b>=> Proceeding with choice 2.</b>"
|
244
|
+
return false
|
245
|
+
elsif @auto
|
246
|
+
puts "<b>=> Proceeding with choice 1.</b>"
|
247
|
+
return true
|
248
|
+
else
|
249
|
+
choice = prompt("Enter your choice (1 or 2) or press Ctrl-C to abort") do |input|
|
250
|
+
if input == "1" || input == "2"
|
251
|
+
true
|
252
|
+
elsif input.empty?
|
253
|
+
puts "<red>No choice has been given.</red>"
|
254
|
+
false
|
255
|
+
else
|
256
|
+
puts "<red>'#{input}' is not a valid choice.</red>"
|
257
|
+
false
|
258
|
+
end
|
259
|
+
end
|
260
|
+
return choice == "1"
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def download_and_extract_pcre
|
265
|
+
new_screen
|
266
|
+
puts "<banner>PCRE (required by Nginx) not installed, downloading it...</banner>"
|
267
|
+
|
268
|
+
url = "http://downloads.sourceforge.net/project/pcre/pcre/#{PREFERRED_PCRE_VERSION}/pcre-#{PREFERRED_PCRE_VERSION}.tar.gz"
|
269
|
+
dirname = "pcre-#{PREFERRED_PCRE_VERSION}"
|
270
|
+
tarball = "#{@working_dir}/pcre.tar.gz"
|
271
|
+
|
272
|
+
if download(url, tarball, DOWNLOAD_OPTION)
|
273
|
+
Dir.chdir(@working_dir) do
|
274
|
+
puts "<banner>Verifying PCRE checksum...</banner>"
|
275
|
+
if sha256_file(tarball) != PCRE_SHA256_CHECKSUM
|
276
|
+
new_screen
|
277
|
+
render_template "nginx/pcre_checksum_could_not_be_verified"
|
278
|
+
wait
|
279
|
+
return nil
|
280
|
+
end
|
281
|
+
|
282
|
+
puts "<banner>Extracting PCRE source tarball...</banner>"
|
283
|
+
if sh("tar", "xzvf", tarball)
|
284
|
+
return "#{@working_dir}/#{dirname}"
|
285
|
+
else
|
286
|
+
new_screen
|
287
|
+
render_template "nginx/pcre_could_not_be_extracted"
|
288
|
+
wait
|
289
|
+
return nil
|
290
|
+
end
|
291
|
+
end
|
292
|
+
else
|
293
|
+
new_screen
|
294
|
+
render_template "nginx/pcre_could_not_be_downloaded"
|
295
|
+
wait
|
296
|
+
return nil
|
297
|
+
end
|
298
|
+
rescue Interrupt
|
299
|
+
exit 2
|
300
|
+
end
|
301
|
+
|
302
|
+
def download_and_extract_nginx
|
303
|
+
new_screen
|
304
|
+
puts "<banner>Downloading Nginx...</banner>"
|
305
|
+
|
306
|
+
url = "http://www.nginx.org/download/nginx-#{PREFERRED_NGINX_VERSION}.tar.gz"
|
307
|
+
dirname = "nginx-#{PREFERRED_NGINX_VERSION}"
|
308
|
+
tarball = "#{@working_dir}/nginx.tar.gz"
|
309
|
+
|
310
|
+
if download(url, tarball, DOWNLOAD_OPTION)
|
311
|
+
Dir.chdir(@working_dir) do
|
312
|
+
puts "<banner>Verifying Nginx checksum...</banner>"
|
313
|
+
if sha256_file(tarball) != NGINX_SHA256_CHECKSUM
|
314
|
+
return nil
|
315
|
+
end
|
316
|
+
|
317
|
+
puts "<banner>Extracting Nginx source tarball...</banner>"
|
318
|
+
if sh("tar", "xzvf", tarball)
|
319
|
+
return "#{@working_dir}/#{dirname}"
|
320
|
+
else
|
321
|
+
return nil
|
322
|
+
end
|
323
|
+
end
|
324
|
+
else
|
325
|
+
return nil
|
326
|
+
end
|
327
|
+
rescue Interrupt
|
328
|
+
exit 2
|
329
|
+
end
|
330
|
+
|
331
|
+
def show_possible_solutions_for_download_and_extraction_problems
|
332
|
+
new_screen
|
333
|
+
render_template "nginx/possible_solutions_for_download_and_extraction_problems"
|
334
|
+
puts
|
335
|
+
end
|
336
|
+
|
337
|
+
def ask_for_nginx_install_prefix
|
338
|
+
new_screen
|
339
|
+
puts "<banner>Where do you want to install Nginx to?</banner>"
|
340
|
+
puts
|
341
|
+
if @prefix
|
342
|
+
puts "<b>=> #{@prefix}</b>"
|
343
|
+
return @prefix
|
344
|
+
elsif @auto
|
345
|
+
puts "<b>=> /opt/nginx</b>"
|
346
|
+
return "/opt/nginx"
|
347
|
+
else
|
348
|
+
prefix = prompt("Please specify a prefix directory [/opt/nginx]") do |input|
|
349
|
+
if input.empty? || input =~ %r(/)
|
350
|
+
true
|
351
|
+
else
|
352
|
+
puts "<red>Please specify an absolute path.</red>"
|
353
|
+
false
|
354
|
+
end
|
355
|
+
end
|
356
|
+
if prefix.empty?
|
357
|
+
prefix = "/opt/nginx"
|
358
|
+
end
|
359
|
+
return prefix
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
def check_whether_other_nginx_installations_exist(nginx_prefix)
|
364
|
+
check_for = [
|
365
|
+
"/usr/bin/nginx",
|
366
|
+
"/usr/sbin/nginx"
|
367
|
+
]
|
368
|
+
existing_binary = nil
|
369
|
+
check_for.each do |filename|
|
370
|
+
if File.exist?(filename)
|
371
|
+
existing_binary = filename
|
372
|
+
break
|
373
|
+
end
|
374
|
+
end
|
375
|
+
if existing_binary
|
376
|
+
new_screen
|
377
|
+
render_template 'nginx/other_nginx_installations_exist',
|
378
|
+
:existing_binary => existing_binary,
|
379
|
+
:prefix => nginx_prefix
|
380
|
+
wait
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
def ask_for_nginx_source_dir
|
385
|
+
new_screen
|
386
|
+
puts "<banner>Where is your Nginx source code located?</banner>"
|
387
|
+
puts
|
388
|
+
if @nginx_source_dir
|
389
|
+
puts "<b>=> #{@nginx_source_dir}</b>"
|
390
|
+
return @nginx_source_dir
|
391
|
+
else
|
392
|
+
return prompt("Please specify the directory") do |input|
|
393
|
+
if input =~ %r(/)
|
394
|
+
if File.exist?("#{input}/src/core/nginx.c")
|
395
|
+
true
|
396
|
+
else
|
397
|
+
puts "<red>'#{input}' does not look like an Nginx source directory.</red>"
|
398
|
+
false
|
399
|
+
end
|
400
|
+
else
|
401
|
+
puts "<red>Please specify an absolute path.</red>"
|
402
|
+
false
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
def ask_for_extra_nginx_configure_flags(prefix)
|
409
|
+
done = false
|
410
|
+
while !done
|
411
|
+
new_screen
|
412
|
+
render_template 'nginx/ask_for_extra_configure_flags',
|
413
|
+
:command => build_nginx_configure_command(prefix)
|
414
|
+
puts
|
415
|
+
if @extra_configure_flags
|
416
|
+
if @extra_configure_flags == "none"
|
417
|
+
extra_args = ""
|
418
|
+
puts "<b>=> No extra configure flags.</b>"
|
419
|
+
else
|
420
|
+
extra_args = @extra_configure_flags
|
421
|
+
puts "<b>=> #{extra_args}</b>"
|
422
|
+
end
|
423
|
+
return extra_args
|
424
|
+
elsif @auto
|
425
|
+
puts "<b>=> No extra configure flags.</b>"
|
426
|
+
return ""
|
427
|
+
else
|
428
|
+
extra_args = prompt "Extra arguments to pass to configure script"
|
429
|
+
|
430
|
+
new_screen
|
431
|
+
render_template 'nginx/confirm_extra_configure_flags',
|
432
|
+
:command => build_nginx_configure_command(prefix, extra_args)
|
433
|
+
puts
|
434
|
+
answer = prompt("Is this what you want? (yes/no) [default=yes]") do |input|
|
435
|
+
if input.empty? || input == "yes" || input == "no"
|
436
|
+
true
|
437
|
+
else
|
438
|
+
puts "<red>Please enter 'yes' or 'no'.</red>"
|
439
|
+
false
|
440
|
+
end
|
441
|
+
end
|
442
|
+
done = answer.empty? || answer == "yes"
|
443
|
+
end
|
444
|
+
end
|
445
|
+
return extra_args
|
446
|
+
end
|
447
|
+
|
448
|
+
def check_whether_we_can_write_to(dir)
|
449
|
+
FileUtils.mkdir_p(dir)
|
450
|
+
File.new("#{dir}/__test__.txt", "w").close
|
451
|
+
return true
|
452
|
+
rescue
|
453
|
+
new_screen
|
454
|
+
if Process.uid == 0
|
455
|
+
render_template 'nginx/cannot_write_to_dir', :dir => dir
|
456
|
+
else
|
457
|
+
render_template 'installer_common/run_installer_as_root',
|
458
|
+
:dir => dir,
|
459
|
+
:sudo => PhusionPassenger::PlatformInfo.ruby_sudo_command,
|
460
|
+
:sudo_s_e => PhusionPassenger::PlatformInfo.ruby_sudo_shell_command("-E"),
|
461
|
+
:ruby => PhusionPassenger::PlatformInfo.ruby_command,
|
462
|
+
:installer => "#{PhusionPassenger.bin_dir}/passenger-install-nginx-module #{ORIG_ARGV.join(' ')}"
|
463
|
+
end
|
464
|
+
return false
|
465
|
+
ensure
|
466
|
+
File.unlink("#{dir}/__test__.txt") rescue nil
|
467
|
+
end
|
468
|
+
|
469
|
+
def nginx_config_exists?(prefix)
|
470
|
+
return !!locate_nginx_config_file(prefix)
|
471
|
+
end
|
472
|
+
|
473
|
+
def install_nginx(source_dir, prefix, extra_configure_flags)
|
474
|
+
Dir.chdir(source_dir) do
|
475
|
+
new_screen
|
476
|
+
puts "<banner>Compiling and installing Nginx...</banner>"
|
477
|
+
if !sh(build_nginx_configure_command(prefix, extra_configure_flags)) ||
|
478
|
+
!sh("make") ||
|
479
|
+
!sh("make install")
|
480
|
+
return false
|
481
|
+
end
|
482
|
+
end
|
483
|
+
return true
|
484
|
+
rescue Interrupt
|
485
|
+
raise Aborted
|
486
|
+
end
|
487
|
+
|
488
|
+
def show_passenger_config_snippets(prefix)
|
489
|
+
new_screen
|
490
|
+
render_template 'nginx/config_snippets',
|
491
|
+
:config_file => locate_nginx_config_file(prefix),
|
492
|
+
:passenger_root => PhusionPassenger.install_spec,
|
493
|
+
:ruby => PlatformInfo.ruby_command
|
494
|
+
wait
|
495
|
+
end
|
496
|
+
|
497
|
+
def show_deployment_example
|
498
|
+
line
|
499
|
+
puts
|
500
|
+
render_template 'nginx/deployment_example',
|
501
|
+
:users_guide_path => users_guide_path,
|
502
|
+
:users_guide_url => users_guide_url,
|
503
|
+
:phusion_website => PHUSION_WEBSITE,
|
504
|
+
:passenger_website => PASSENGER_WEBSITE
|
505
|
+
end
|
506
|
+
|
507
|
+
def show_possible_solutions_for_compilation_and_installation_problems
|
508
|
+
line
|
509
|
+
puts
|
510
|
+
render_template 'nginx/possible_solutions_for_compilation_and_installation_problems',
|
511
|
+
:users_guide_path => users_guide_path,
|
512
|
+
:users_guide_url => users_guide_url,
|
513
|
+
:support_url => SUPPORT_URL
|
514
|
+
end
|
515
|
+
|
516
|
+
def locate_nginx_config_file(prefix)
|
517
|
+
["#{prefix}/conf/nginx.conf", "#{prefix}/etc/nginx.conf"].each do |filename|
|
518
|
+
if File.exist?(filename)
|
519
|
+
return filename
|
520
|
+
end
|
521
|
+
end
|
522
|
+
return nil
|
523
|
+
end
|
524
|
+
|
525
|
+
def insert_passenger_config_snippets(prefix)
|
526
|
+
config_file = locate_nginx_config_file(prefix)
|
527
|
+
contents = File.read(config_file)
|
528
|
+
contents.sub!(/^http \{/,
|
529
|
+
"http {\n" <<
|
530
|
+
" passenger_root #{PhusionPassenger.install_spec};\n" <<
|
531
|
+
" passenger_ruby #{PlatformInfo.ruby_command};\n")
|
532
|
+
File.open(config_file, 'w') do |f|
|
533
|
+
f.write(contents)
|
534
|
+
end
|
535
|
+
|
536
|
+
new_screen
|
537
|
+
render_template 'nginx/config_snippets_inserted',
|
538
|
+
:config_file => config_file,
|
539
|
+
:passenger_root => PhusionPassenger.install_spec,
|
540
|
+
:ruby => PlatformInfo.ruby_command
|
541
|
+
wait
|
542
|
+
end
|
543
|
+
|
544
|
+
def build_nginx_configure_command(prefix, extra_configure_flags = nil)
|
545
|
+
command = "sh ./configure --prefix='#{prefix}' "
|
546
|
+
command << "--with-http_ssl_module "
|
547
|
+
command << "--with-http_gzip_static_module "
|
548
|
+
command << "--with-http_stub_status_module "
|
549
|
+
command << "--with-cc-opt='-Wno-error' "
|
550
|
+
if @pcre_source_dir
|
551
|
+
command << "--with-pcre='#{@pcre_source_dir}' "
|
552
|
+
elsif !pcre_is_installed?
|
553
|
+
command << "--without-http_rewrite_module "
|
554
|
+
end
|
555
|
+
command << "--add-module='#{PhusionPassenger.nginx_module_source_dir}' #{extra_configure_flags}"
|
556
|
+
command.strip!
|
557
|
+
return command
|
558
|
+
end
|
559
|
+
|
560
|
+
def pcre_is_installed?
|
561
|
+
if @pcre_is_installed.nil?
|
562
|
+
@pcre_is_installed = begin
|
563
|
+
File.open('/tmp/passenger-check.c', 'w') do |f|
|
564
|
+
f.puts("#include <pcre.h>")
|
565
|
+
end
|
566
|
+
Dir.chdir('/tmp') do
|
567
|
+
# Nginx checks for PCRE in multiple places...
|
568
|
+
system("(gcc -I/usr/local/include -I/usr/include/pcre " <<
|
569
|
+
"-I/usr/pkg/include -I/opt/local/include " <<
|
570
|
+
"-c passenger-check.c) >/dev/null 2>/dev/null")
|
571
|
+
end
|
572
|
+
ensure
|
573
|
+
File.unlink('/tmp/passenger-check.c') rescue nil
|
574
|
+
File.unlink('/tmp/passenger-check.o') rescue nil
|
575
|
+
end
|
576
|
+
end
|
577
|
+
return @pcre_is_installed
|
578
|
+
end
|
579
|
+
|
580
|
+
def sha256_file(path)
|
581
|
+
# We do this instead of using #file, for Ruby 1.8.5 support.
|
582
|
+
digest = Digest::SHA256.new
|
583
|
+
File.open(path, "rb") do |f|
|
584
|
+
buf = ''
|
585
|
+
buf.force_encoding('binary') if buf.respond_to?(:force_encoding)
|
586
|
+
while !f.eof?
|
587
|
+
f.read(1024 * 16, buf)
|
588
|
+
digest.update(buf)
|
589
|
+
end
|
590
|
+
end
|
591
|
+
return digest.hexdigest
|
592
|
+
end
|
593
593
|
end
|
594
594
|
|
595
595
|
ORIG_ARGV = ARGV.dup
|
596
596
|
options = {}
|
597
597
|
parser = OptionParser.new do |opts|
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
598
|
+
opts.banner = "Usage: passenger-install-nginx-module [options]"
|
599
|
+
opts.separator ""
|
600
|
+
|
601
|
+
indent = ' ' * 37
|
602
|
+
opts.separator "Options:"
|
603
|
+
opts.on("--auto", "Automatically confirm 'Press ENTER to\n" <<
|
604
|
+
"#{indent}continue' prompts.") do
|
605
|
+
options[:auto] = true
|
606
|
+
end
|
607
|
+
opts.on("--prefix=DIR", String, "Use the given Nginx install prefix instead\n" <<
|
608
|
+
"#{indent}of asking for it interactively.") do |dir|
|
609
|
+
options[:prefix] = dir
|
610
|
+
end
|
611
|
+
opts.on("--auto-download", "Download and install Nginx automatically,\n" <<
|
612
|
+
"#{indent}instead of asking interactively whether to\n" <<
|
613
|
+
"#{indent}download+install or to use an existing\n" <<
|
614
|
+
"#{indent}Nginx source directory.") do
|
615
|
+
options[:auto_download] = true
|
616
|
+
end
|
617
|
+
opts.on("--nginx-source-dir=DIR", String, "Compile and install Nginx using the given\n" <<
|
618
|
+
"#{indent}Nginx source directory, instead of\n" <<
|
619
|
+
"#{indent}interactively asking to download+install\n" <<
|
620
|
+
"#{indent}or to use an existing Nginx source\n" <<
|
621
|
+
"#{indent}directory. Conflicts with --auto-download.") do |dir|
|
622
|
+
options[:nginx_source_dir] = dir
|
623
|
+
end
|
624
|
+
opts.on("--extra-configure-flags=STRING", String, "Pass these extra flags to Nginx's\n" <<
|
625
|
+
"#{indent}'configure' script, instead of asking for\n" <<
|
626
|
+
"#{indent}it interactively. Specify 'none' if you\n" <<
|
627
|
+
"#{indent}do not want to pass additional flags but do\n" <<
|
628
|
+
"#{indent}not want this installer to ask\n" <<
|
629
|
+
"#{indent}interactively either.") do |flags|
|
630
|
+
options[:extra_configure_flags] = flags
|
631
|
+
end
|
632
|
+
opts.on("--languages NAMES", "Comma-separated list of interested\n" <<
|
633
|
+
"#{indent}languages (e.g.\n" <<
|
634
|
+
"#{indent}'ruby,python,nodejs,meteor')") do |value|
|
635
|
+
options[:languages] = value.split(",")
|
636
|
+
end
|
637
|
+
opts.on("--force-colors", "Display colors even if stdout is not a TTY") do
|
638
|
+
options[:colorize] = true
|
639
|
+
end
|
640
640
|
end
|
641
641
|
begin
|
642
|
-
|
642
|
+
parser.parse!
|
643
643
|
rescue OptionParser::ParseError => e
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
644
|
+
puts e
|
645
|
+
puts
|
646
|
+
puts "Please see '--help' for valid options."
|
647
|
+
exit 1
|
648
648
|
end
|
649
649
|
|
650
650
|
if options[:auto_download] && options[:nginx_source_dir]
|
651
|
-
|
652
|
-
|
651
|
+
STDERR.puts "You cannot specify both --auto-download and --nginx-source-dir."
|
652
|
+
exit 1
|
653
653
|
end
|
654
654
|
|
655
655
|
Installer.new(options).run
|