passenger 4.0.30 → 4.0.31

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

Potentially problematic release.


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

Files changed (409) hide show
  1. data.tar.gz.asc +7 -7
  2. data/NEWS +31 -0
  3. data/bin/passenger +5 -5
  4. data/bin/passenger-config +6 -126
  5. data/bin/passenger-install-apache2-module +108 -26
  6. data/bin/passenger-install-nginx-module +81 -27
  7. data/bin/passenger-memory-stats +7 -6
  8. data/bin/passenger-status +13 -10
  9. data/build/agents.rb +8 -12
  10. data/build/apache2.rb +12 -7
  11. data/build/basics.rb +28 -20
  12. data/build/common_library.rb +4 -4
  13. data/build/cplusplus_support.rb +4 -4
  14. data/build/cxx_tests.rb +5 -3
  15. data/build/debian.rb +1 -2
  16. data/build/integration_tests.rb +25 -9
  17. data/build/misc.rb +2 -2
  18. data/build/oxt_tests.rb +5 -6
  19. data/build/packaging.rb +72 -40
  20. data/build/ruby_tests.rb +5 -1
  21. data/build/test_basics.rb +1 -2
  22. data/debian.template/locations.ini.template +1 -0
  23. data/debian.template/rules.template +2 -1
  24. data/dev/install_scripts_bootstrap_code.rb +42 -0
  25. data/dev/run_travis.sh +1 -0
  26. data/dev/runner +27 -0
  27. data/doc/Packaging.txt.md +5 -10
  28. data/doc/Users guide Apache.idmap.txt +3 -1
  29. data/doc/Users guide Apache.txt +5 -3
  30. data/doc/Users guide Nginx.idmap.txt +9 -5
  31. data/doc/Users guide Nginx.txt +47 -17
  32. data/doc/users_guide_snippets/environment_variables.txt +2 -2
  33. data/doc/users_guide_snippets/installation.txt +6 -2
  34. data/doc/users_guide_snippets/tips.txt +4 -0
  35. data/ext/apache2/Hooks.cpp +16 -3
  36. data/ext/common/Account.h +6 -5
  37. data/ext/common/AgentsStarter.h +1 -1
  38. data/ext/common/ApplicationPool2/Common.h +72 -0
  39. data/ext/common/ApplicationPool2/Group.h +263 -148
  40. data/ext/common/ApplicationPool2/Implementation.cpp +66 -44
  41. data/ext/common/ApplicationPool2/Options.h +1 -7
  42. data/ext/common/ApplicationPool2/Pool.h +96 -72
  43. data/ext/common/ApplicationPool2/Process.h +12 -17
  44. data/ext/common/ApplicationPool2/Socket.h +4 -4
  45. data/ext/common/ApplicationPool2/SuperGroup.h +20 -17
  46. data/ext/common/Constants.h +15 -1
  47. data/ext/common/MessageServer.h +22 -0
  48. data/ext/common/Utils.cpp +4 -1
  49. data/ext/common/Utils.h +3 -1
  50. data/ext/common/Utils/StrIntUtils.h +1 -0
  51. data/ext/common/Utils/Timer.h +15 -1
  52. data/ext/common/Utils/utf8/checked.h +0 -0
  53. data/ext/common/Utils/utf8/core.h +0 -0
  54. data/ext/common/Utils/utf8/unchecked.h +0 -0
  55. data/ext/common/agents/Base.cpp +59 -35
  56. data/ext/common/agents/HelperAgent/Main.cpp +23 -12
  57. data/ext/common/agents/HelperAgent/RequestHandler.h +10 -1
  58. data/ext/common/agents/LoggingAgent/FilterSupport.h +9 -5
  59. data/ext/common/agents/TempDirToucher.c +12 -3
  60. data/ext/common/agents/Watchdog/Main.cpp +8 -2
  61. data/ext/nginx/ConfigurationCommands.c +10 -0
  62. data/ext/nginx/ConfigurationFields.h +2 -0
  63. data/ext/nginx/ContentHandler.c +32 -19
  64. data/ext/nginx/CreateLocationConfig.c +5 -0
  65. data/ext/nginx/MergeLocationConfig.c +6 -0
  66. data/ext/nginx/config +13 -6
  67. data/ext/ruby/passenger_native_support.c +61 -2
  68. data/helper-scripts/classic-rails-loader.rb +9 -10
  69. data/helper-scripts/classic-rails-preloader.rb +10 -11
  70. data/helper-scripts/node-loader.js +3 -2
  71. data/helper-scripts/rack-loader.rb +8 -9
  72. data/helper-scripts/rack-preloader.rb +9 -10
  73. data/lib/phusion_passenger.rb +36 -7
  74. data/lib/phusion_passenger/abstract_installer.rb +16 -15
  75. data/lib/phusion_passenger/active_support3_extensions/init.rb +1 -1
  76. data/lib/phusion_passenger/admin_tools/memory_stats.rb +2 -2
  77. data/lib/phusion_passenger/admin_tools/server_instance.rb +5 -5
  78. data/lib/phusion_passenger/analytics_logger.rb +3 -3
  79. data/lib/phusion_passenger/classic_rails/thread_handler_extension.rb +1 -1
  80. data/lib/phusion_passenger/config.rb +125 -0
  81. data/lib/phusion_passenger/config/about_command.rb +183 -0
  82. data/lib/phusion_passenger/config/command.rb +57 -0
  83. data/lib/phusion_passenger/config/restart_app_command.rb +146 -0
  84. data/lib/phusion_passenger/config/utils.rb +108 -0
  85. data/lib/phusion_passenger/console_text_template.rb +2 -1
  86. data/lib/phusion_passenger/constants.rb +7 -2
  87. data/lib/phusion_passenger/loader_shared_helpers.rb +12 -21
  88. data/lib/phusion_passenger/message_client.rb +15 -4
  89. data/lib/phusion_passenger/native_support.rb +116 -98
  90. data/lib/phusion_passenger/nginx/config_options.rb +5 -0
  91. data/lib/phusion_passenger/platform_info.rb +1 -1
  92. data/lib/phusion_passenger/platform_info/apache.rb +9 -5
  93. data/lib/phusion_passenger/platform_info/apache_detector.rb +5 -6
  94. data/lib/phusion_passenger/platform_info/binary_compatibility.rb +3 -3
  95. data/lib/phusion_passenger/platform_info/compiler.rb +29 -11
  96. data/lib/phusion_passenger/platform_info/curl.rb +1 -1
  97. data/lib/phusion_passenger/platform_info/cxx_portability.rb +30 -16
  98. data/lib/phusion_passenger/platform_info/depcheck.rb +6 -6
  99. data/lib/phusion_passenger/platform_info/linux.rb +2 -2
  100. data/lib/phusion_passenger/platform_info/operating_system.rb +25 -5
  101. data/lib/phusion_passenger/platform_info/ruby.rb +7 -4
  102. data/lib/phusion_passenger/platform_info/zlib.rb +1 -1
  103. data/lib/phusion_passenger/plugin.rb +0 -1
  104. data/lib/phusion_passenger/preloader_shared_helpers.rb +1 -1
  105. data/lib/phusion_passenger/public_api.rb +1 -1
  106. data/lib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
  107. data/lib/phusion_passenger/request_handler.rb +8 -9
  108. data/lib/phusion_passenger/request_handler/thread_handler.rb +21 -9
  109. data/lib/phusion_passenger/ruby_core_enhancements.rb +1 -1
  110. data/lib/phusion_passenger/standalone/app_finder.rb +2 -2
  111. data/lib/phusion_passenger/standalone/command.rb +10 -8
  112. data/lib/phusion_passenger/standalone/help_command.rb +1 -1
  113. data/lib/phusion_passenger/standalone/main.rb +3 -3
  114. data/lib/phusion_passenger/standalone/package_runtime_command.rb +2 -2
  115. data/lib/phusion_passenger/standalone/runtime_installer.rb +55 -13
  116. data/lib/phusion_passenger/standalone/runtime_locator.rb +3 -3
  117. data/lib/phusion_passenger/standalone/start_command.rb +6 -7
  118. data/lib/phusion_passenger/standalone/status_command.rb +1 -1
  119. data/lib/phusion_passenger/standalone/stop_command.rb +1 -1
  120. data/lib/phusion_passenger/standalone/utils.rb +1 -1
  121. data/lib/phusion_passenger/standalone/version_command.rb +2 -3
  122. data/lib/phusion_passenger/utils.rb +1 -1
  123. data/lib/phusion_passenger/utils/download.rb +1 -2
  124. data/lib/phusion_passenger/utils/file_system_watcher.rb +1 -1
  125. data/lib/phusion_passenger/utils/hosts_file_parser.rb +1 -1
  126. data/lib/phusion_passenger/utils/tee_input.rb +1 -1
  127. data/lib/phusion_passenger/utils/terminal_choice_menu.rb +217 -0
  128. data/lib/phusion_passenger/utils/unseekable_socket.rb +1 -1
  129. data/resources/templates/apache2/config_snippets.txt.erb +2 -3
  130. data/resources/templates/apache2/deployment_example.txt.erb +2 -2
  131. data/resources/templates/apache2/notify_apache_module_installed.txt.erb +3 -0
  132. data/resources/templates/nginx/config_snippets.txt.erb +1 -1
  133. data/resources/templates/nginx/deployment_example.txt.erb +2 -2
  134. data/resources/templates/nginx/nginx_module_sources_not_available.txt.erb +11 -5
  135. data/rpm/Vagrantfile +1 -0
  136. data/test/cxx/ApplicationPool2/PoolTest.cpp +224 -35
  137. data/test/cxx/ApplicationPool2/ProcessTest.cpp +6 -6
  138. data/test/cxx/MessagePassingTest.cpp +1 -1
  139. data/test/cxx/RequestHandlerTest.cpp +26 -26
  140. data/test/integration_tests/apache2_tests.rb +162 -243
  141. data/test/integration_tests/native_packaging_spec.rb +10 -10
  142. data/test/integration_tests/nginx_tests.rb +87 -107
  143. data/test/integration_tests/shared/example_webapp_tests.rb +246 -0
  144. data/test/integration_tests/source_packaging_test.rb +2 -1
  145. data/test/integration_tests/standalone_tests.rb +34 -19
  146. data/test/ruby/admin_tools_spec.rb +4 -4
  147. data/test/ruby/analytics_logger_spec.rb +1 -1
  148. data/test/ruby/debug_logging_spec.rb +2 -2
  149. data/test/ruby/message_channel_spec.rb +1 -1
  150. data/test/ruby/request_handler_spec.rb +171 -64
  151. data/test/ruby/shared/loader_sharedspec.rb +5 -5
  152. data/test/ruby/shared/rails/analytics_logging_extensions_sharedspec.rb +2 -2
  153. data/test/ruby/spec_helper.rb +4 -4
  154. data/test/ruby/standalone/runtime_installer_spec.rb +1 -1
  155. data/test/ruby/standalone/runtime_locator_spec.rb +1 -1
  156. data/test/ruby/utils/file_system_watcher_spec.rb +1 -1
  157. data/test/ruby/utils/hosts_file_parser.rb +1 -1
  158. data/test/ruby/utils/unseekable_socket_spec.rb +1 -1
  159. data/test/ruby/utils_spec.rb +4 -4
  160. data/test/stub/apache2/httpd.conf.erb +5 -0
  161. data/test/stub/index.html +1 -0
  162. data/test/stub/rack/config.ru +80 -33
  163. data/test/stub/{rails_apps/1.2/empty/app/models → rack/public}/.gitignore +0 -0
  164. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/Rakefile +0 -0
  165. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/application_controller.rb +0 -0
  166. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/recipes_controller.rb +0 -0
  167. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/uploads_controller.rb +0 -0
  168. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/welcome_controller.rb +0 -0
  169. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/app/helpers/application_helper.rb +0 -0
  170. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/recipes_helper.rb +0 -0
  171. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/test_helper.rb +0 -0
  172. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/uploads_helper.rb +0 -0
  173. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/welcome_helper.rb +0 -0
  174. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/layouts/default.rhtml +0 -0
  175. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/recipes/create.rhtml +0 -0
  176. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/recipes/index.rhtml +0 -0
  177. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/recipes/new.rhtml +0 -0
  178. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/uploads/index.rhtml +0 -0
  179. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/uploads/new.html.erb +0 -0
  180. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/welcome/cached.rhtml +0 -0
  181. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/welcome/index.rhtml +0 -0
  182. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/boot.rb +0 -0
  183. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/database.yml +0 -0
  184. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/environment.rb +0 -0
  185. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/config/environments/development.rb +0 -0
  186. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/environments/production.rb +0 -0
  187. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/config/initializers/inflections.rb +0 -0
  188. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/config/initializers/mime_types.rb +0 -0
  189. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/routes.rb +0 -0
  190. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/log/useless.txt +0 -0
  191. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/.htaccess +0 -0
  192. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/public/404.html +0 -0
  193. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/public/422.html +0 -0
  194. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/public/500.html +0 -0
  195. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/dispatch.cgi +0 -0
  196. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/dispatch.fcgi +0 -0
  197. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/dispatch.rb +0 -0
  198. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/public/favicon.ico +0 -0
  199. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/images/angrywizard.gif +0 -0
  200. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/images/cookbook.gif +0 -0
  201. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/images/header.png +0 -0
  202. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/public/images/rails.png +0 -0
  203. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/public/robots.txt +0 -0
  204. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/uploads.html +0 -0
  205. data/test/stub/{rails_apps/1.2/empty/db → rails2.3-mycook/public/uploads}/.gitignore +0 -0
  206. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/welcome/cached.html +0 -0
  207. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/about +0 -0
  208. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/console +0 -0
  209. data/test/stub/{rails_apps/2.2/empty → rails2.3-mycook}/script/dbconsole +0 -0
  210. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/destroy +0 -0
  211. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/generate +0 -0
  212. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/performance/benchmarker +0 -0
  213. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/performance/profiler +0 -0
  214. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/performance/request +0 -0
  215. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/plugin +0 -0
  216. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/process/inspector +0 -0
  217. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/process/reaper +0 -0
  218. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/process/spawner +0 -0
  219. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/runner +0 -0
  220. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/server +0 -0
  221. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/sites/some.site/public/uploads.html +0 -0
  222. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/sites/some.site/public/welcome/cached.html +0 -0
  223. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/cache/useless.txt +0 -0
  224. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/pids/useless.txt +0 -0
  225. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/sessions/useless.txt +0 -0
  226. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/sockets/useless.txt +0 -0
  227. data/test/stub/rails2.3/app/controllers/foo_controller.rb +1 -1
  228. data/test/stub/rails2.3/config/routes.rb +1 -2
  229. data/test/stub/wsgi/passenger_wsgi.py +47 -8
  230. data/test/stub/{rails_apps/1.2/empty/public/stylesheets → wsgi/public}/.gitignore +0 -0
  231. data/test/support/apache2_controller.rb +2 -2
  232. data/test/support/nginx_controller.rb +11 -5
  233. data/test/support/placebo-preloader.rb +2 -2
  234. data/test/support/test_helper.rb +26 -7
  235. metadata +78 -240
  236. metadata.gz.asc +7 -7
  237. data/debian.template/repack.sh +0 -42
  238. data/debian.template/watch +0 -3
  239. data/test/integration_tests/cgi_environment_spec.rb +0 -36
  240. data/test/integration_tests/hello_world_rack_spec.rb +0 -43
  241. data/test/integration_tests/hello_world_wsgi_spec.rb +0 -41
  242. data/test/integration_tests/mycook_spec.rb +0 -166
  243. data/test/stub/rack/public/rack.jpg +0 -0
  244. data/test/stub/rails_apps/1.2/empty/.gitignore +0 -3
  245. data/test/stub/rails_apps/1.2/empty/app/controllers/application.rb +0 -7
  246. data/test/stub/rails_apps/1.2/empty/config/boot.rb +0 -108
  247. data/test/stub/rails_apps/1.2/empty/config/database.yml +0 -31
  248. data/test/stub/rails_apps/1.2/empty/config/environment.rb +0 -66
  249. data/test/stub/rails_apps/1.2/empty/config/environments/development.rb +0 -21
  250. data/test/stub/rails_apps/1.2/empty/config/environments/production.rb +0 -18
  251. data/test/stub/rails_apps/1.2/empty/config/environments/staging.rb +0 -18
  252. data/test/stub/rails_apps/1.2/empty/config/environments/test.rb +0 -19
  253. data/test/stub/rails_apps/1.2/empty/config/routes.rb +0 -23
  254. data/test/stub/rails_apps/1.2/empty/doc/README_FOR_APP +0 -2
  255. data/test/stub/rails_apps/1.2/empty/public/.htaccess +0 -40
  256. data/test/stub/rails_apps/1.2/empty/public/500.html +0 -30
  257. data/test/stub/rails_apps/1.2/empty/public/dispatch.cgi +0 -10
  258. data/test/stub/rails_apps/1.2/empty/public/dispatch.fcgi +0 -24
  259. data/test/stub/rails_apps/1.2/empty/public/dispatch.rb +0 -10
  260. data/test/stub/rails_apps/1.2/empty/public/robots.txt +0 -1
  261. data/test/stub/rails_apps/1.2/empty/script/about +0 -3
  262. data/test/stub/rails_apps/1.2/empty/script/breakpointer +0 -3
  263. data/test/stub/rails_apps/1.2/empty/script/console +0 -3
  264. data/test/stub/rails_apps/1.2/empty/script/destroy +0 -3
  265. data/test/stub/rails_apps/1.2/empty/script/generate +0 -3
  266. data/test/stub/rails_apps/1.2/empty/script/plugin +0 -3
  267. data/test/stub/rails_apps/1.2/empty/script/runner +0 -3
  268. data/test/stub/rails_apps/1.2/empty/script/server +0 -3
  269. data/test/stub/rails_apps/1.2/empty/test/test_helper.rb +0 -28
  270. data/test/stub/rails_apps/2.0/empty/.gitignore +0 -3
  271. data/test/stub/rails_apps/2.0/empty/Rakefile +0 -10
  272. data/test/stub/rails_apps/2.0/empty/app/controllers/application.rb +0 -10
  273. data/test/stub/rails_apps/2.0/empty/app/helpers/application_helper.rb +0 -3
  274. data/test/stub/rails_apps/2.0/empty/app/models/.gitignore +0 -0
  275. data/test/stub/rails_apps/2.0/empty/config/boot.rb +0 -108
  276. data/test/stub/rails_apps/2.0/empty/config/database.yml +0 -31
  277. data/test/stub/rails_apps/2.0/empty/config/environment.rb +0 -59
  278. data/test/stub/rails_apps/2.0/empty/config/environments/production.rb +0 -18
  279. data/test/stub/rails_apps/2.0/empty/config/environments/staging.rb +0 -18
  280. data/test/stub/rails_apps/2.0/empty/config/environments/test.rb +0 -22
  281. data/test/stub/rails_apps/2.0/empty/config/routes.rb +0 -35
  282. data/test/stub/rails_apps/2.0/empty/db/.gitignore +0 -0
  283. data/test/stub/rails_apps/2.0/empty/doc/README_FOR_APP +0 -2
  284. data/test/stub/rails_apps/2.0/empty/public/.htaccess +0 -40
  285. data/test/stub/rails_apps/2.0/empty/public/404.html +0 -30
  286. data/test/stub/rails_apps/2.0/empty/public/dispatch.cgi +0 -10
  287. data/test/stub/rails_apps/2.0/empty/public/dispatch.fcgi +0 -24
  288. data/test/stub/rails_apps/2.0/empty/public/dispatch.rb +0 -10
  289. data/test/stub/rails_apps/2.0/empty/public/favicon.ico +0 -0
  290. data/test/stub/rails_apps/2.0/empty/public/images/rails.png +0 -0
  291. data/test/stub/rails_apps/2.0/empty/public/stylesheets/.gitignore +0 -0
  292. data/test/stub/rails_apps/2.0/empty/script/performance/benchmarker +0 -3
  293. data/test/stub/rails_apps/2.0/empty/script/performance/profiler +0 -3
  294. data/test/stub/rails_apps/2.0/empty/script/process/inspector +0 -3
  295. data/test/stub/rails_apps/2.0/empty/script/process/reaper +0 -3
  296. data/test/stub/rails_apps/2.0/empty/script/process/spawner +0 -3
  297. data/test/stub/rails_apps/2.0/empty/test/test_helper.rb +0 -38
  298. data/test/stub/rails_apps/2.2/empty/.gitignore +0 -3
  299. data/test/stub/rails_apps/2.2/empty/Rakefile +0 -10
  300. data/test/stub/rails_apps/2.2/empty/app/controllers/application.rb +0 -15
  301. data/test/stub/rails_apps/2.2/empty/app/helpers/application_helper.rb +0 -3
  302. data/test/stub/rails_apps/2.2/empty/app/models/.gitignore +0 -0
  303. data/test/stub/rails_apps/2.2/empty/config/boot.rb +0 -109
  304. data/test/stub/rails_apps/2.2/empty/config/database.yml +0 -31
  305. data/test/stub/rails_apps/2.2/empty/config/environment.rb +0 -75
  306. data/test/stub/rails_apps/2.2/empty/config/environments/development.rb +0 -17
  307. data/test/stub/rails_apps/2.2/empty/config/environments/production.rb +0 -24
  308. data/test/stub/rails_apps/2.2/empty/config/environments/staging.rb +0 -24
  309. data/test/stub/rails_apps/2.2/empty/config/environments/test.rb +0 -22
  310. data/test/stub/rails_apps/2.2/empty/config/initializers/inflections.rb +0 -10
  311. data/test/stub/rails_apps/2.2/empty/config/initializers/mime_types.rb +0 -5
  312. data/test/stub/rails_apps/2.2/empty/config/initializers/new_rails_defaults.rb +0 -17
  313. data/test/stub/rails_apps/2.2/empty/config/locales/en.yml +0 -5
  314. data/test/stub/rails_apps/2.2/empty/config/routes.rb +0 -43
  315. data/test/stub/rails_apps/2.2/empty/db/.gitignore +0 -0
  316. data/test/stub/rails_apps/2.2/empty/doc/README_FOR_APP +0 -5
  317. data/test/stub/rails_apps/2.2/empty/public/404.html +0 -30
  318. data/test/stub/rails_apps/2.2/empty/public/422.html +0 -30
  319. data/test/stub/rails_apps/2.2/empty/public/500.html +0 -33
  320. data/test/stub/rails_apps/2.2/empty/public/dispatch.cgi +0 -10
  321. data/test/stub/rails_apps/2.2/empty/public/dispatch.fcgi +0 -24
  322. data/test/stub/rails_apps/2.2/empty/public/dispatch.rb +0 -10
  323. data/test/stub/rails_apps/2.2/empty/public/favicon.ico +0 -0
  324. data/test/stub/rails_apps/2.2/empty/public/images/rails.png +0 -0
  325. data/test/stub/rails_apps/2.2/empty/public/robots.txt +0 -5
  326. data/test/stub/rails_apps/2.2/empty/public/stylesheets/.gitignore +0 -0
  327. data/test/stub/rails_apps/2.2/empty/script/about +0 -4
  328. data/test/stub/rails_apps/2.2/empty/script/console +0 -3
  329. data/test/stub/rails_apps/2.2/empty/script/destroy +0 -3
  330. data/test/stub/rails_apps/2.2/empty/script/generate +0 -3
  331. data/test/stub/rails_apps/2.2/empty/script/performance/benchmarker +0 -3
  332. data/test/stub/rails_apps/2.2/empty/script/performance/profiler +0 -3
  333. data/test/stub/rails_apps/2.2/empty/script/performance/request +0 -3
  334. data/test/stub/rails_apps/2.2/empty/script/plugin +0 -3
  335. data/test/stub/rails_apps/2.2/empty/script/process/inspector +0 -3
  336. data/test/stub/rails_apps/2.2/empty/script/process/reaper +0 -3
  337. data/test/stub/rails_apps/2.2/empty/script/process/spawner +0 -3
  338. data/test/stub/rails_apps/2.2/empty/script/runner +0 -3
  339. data/test/stub/rails_apps/2.2/empty/script/server +0 -3
  340. data/test/stub/rails_apps/2.2/empty/test/performance/browsing_test.rb +0 -9
  341. data/test/stub/rails_apps/2.2/empty/test/test_helper.rb +0 -38
  342. data/test/stub/rails_apps/2.3/empty/.gitignore +0 -3
  343. data/test/stub/rails_apps/2.3/empty/Rakefile +0 -10
  344. data/test/stub/rails_apps/2.3/empty/app/controllers/application_controller.rb +0 -10
  345. data/test/stub/rails_apps/2.3/empty/app/helpers/application_helper.rb +0 -3
  346. data/test/stub/rails_apps/2.3/empty/app/models/.gitignore +0 -0
  347. data/test/stub/rails_apps/2.3/empty/config/boot.rb +0 -110
  348. data/test/stub/rails_apps/2.3/empty/config/database.yml +0 -31
  349. data/test/stub/rails_apps/2.3/empty/config/environment.rb +0 -41
  350. data/test/stub/rails_apps/2.3/empty/config/environments/development.rb +0 -17
  351. data/test/stub/rails_apps/2.3/empty/config/environments/production.rb +0 -28
  352. data/test/stub/rails_apps/2.3/empty/config/environments/staging.rb +0 -28
  353. data/test/stub/rails_apps/2.3/empty/config/environments/test.rb +0 -28
  354. data/test/stub/rails_apps/2.3/empty/config/initializers/backtrace_silencers.rb +0 -7
  355. data/test/stub/rails_apps/2.3/empty/config/initializers/inflections.rb +0 -10
  356. data/test/stub/rails_apps/2.3/empty/config/initializers/mime_types.rb +0 -5
  357. data/test/stub/rails_apps/2.3/empty/config/initializers/new_rails_defaults.rb +0 -21
  358. data/test/stub/rails_apps/2.3/empty/config/initializers/session_store.rb +0 -15
  359. data/test/stub/rails_apps/2.3/empty/config/locales/en.yml +0 -5
  360. data/test/stub/rails_apps/2.3/empty/config/routes.rb +0 -43
  361. data/test/stub/rails_apps/2.3/empty/db/.gitignore +0 -0
  362. data/test/stub/rails_apps/2.3/empty/db/seeds.rb +0 -7
  363. data/test/stub/rails_apps/2.3/empty/doc/README_FOR_APP +0 -2
  364. data/test/stub/rails_apps/2.3/empty/public/404.html +0 -30
  365. data/test/stub/rails_apps/2.3/empty/public/422.html +0 -30
  366. data/test/stub/rails_apps/2.3/empty/public/500.html +0 -30
  367. data/test/stub/rails_apps/2.3/empty/public/favicon.ico +0 -0
  368. data/test/stub/rails_apps/2.3/empty/public/images/rails.png +0 -0
  369. data/test/stub/rails_apps/2.3/empty/public/robots.txt +0 -5
  370. data/test/stub/rails_apps/2.3/empty/public/stylesheets/.gitignore +0 -0
  371. data/test/stub/rails_apps/2.3/empty/script/about +0 -4
  372. data/test/stub/rails_apps/2.3/empty/script/console +0 -3
  373. data/test/stub/rails_apps/2.3/empty/script/dbconsole +0 -3
  374. data/test/stub/rails_apps/2.3/empty/script/destroy +0 -3
  375. data/test/stub/rails_apps/2.3/empty/script/generate +0 -3
  376. data/test/stub/rails_apps/2.3/empty/script/performance/benchmarker +0 -3
  377. data/test/stub/rails_apps/2.3/empty/script/performance/profiler +0 -3
  378. data/test/stub/rails_apps/2.3/empty/script/plugin +0 -3
  379. data/test/stub/rails_apps/2.3/empty/script/runner +0 -3
  380. data/test/stub/rails_apps/2.3/empty/script/server +0 -3
  381. data/test/stub/rails_apps/2.3/empty/test/performance/browsing_test.rb +0 -9
  382. data/test/stub/rails_apps/2.3/empty/test/test_helper.rb +0 -38
  383. data/test/stub/rails_apps/2.3/mycook/Rakefile +0 -10
  384. data/test/stub/rails_apps/2.3/mycook/app/helpers/application_helper.rb +0 -3
  385. data/test/stub/rails_apps/2.3/mycook/config/environments/development.rb +0 -18
  386. data/test/stub/rails_apps/2.3/mycook/config/initializers/inflections.rb +0 -10
  387. data/test/stub/rails_apps/2.3/mycook/config/initializers/mime_types.rb +0 -5
  388. data/test/stub/rails_apps/2.3/mycook/public/404.html +0 -30
  389. data/test/stub/rails_apps/2.3/mycook/public/422.html +0 -30
  390. data/test/stub/rails_apps/2.3/mycook/public/500.html +0 -30
  391. data/test/stub/rails_apps/2.3/mycook/public/favicon.ico +0 -0
  392. data/test/stub/rails_apps/2.3/mycook/public/images/rails.png +0 -0
  393. data/test/stub/rails_apps/2.3/mycook/public/robots.txt +0 -5
  394. data/test/stub/rails_apps/2.3/mycook/public/uploads/.gitignore +0 -0
  395. data/test/stub/rails_apps/2.3/mycook/script/about +0 -3
  396. data/test/stub/rails_apps/2.3/mycook/script/console +0 -3
  397. data/test/stub/rails_apps/2.3/mycook/script/dbconsole +0 -3
  398. data/test/stub/rails_apps/2.3/mycook/script/destroy +0 -3
  399. data/test/stub/rails_apps/2.3/mycook/script/generate +0 -3
  400. data/test/stub/rails_apps/2.3/mycook/script/performance/benchmarker +0 -3
  401. data/test/stub/rails_apps/2.3/mycook/script/performance/profiler +0 -3
  402. data/test/stub/rails_apps/2.3/mycook/script/performance/request +0 -3
  403. data/test/stub/rails_apps/2.3/mycook/script/plugin +0 -3
  404. data/test/stub/rails_apps/2.3/mycook/script/process/inspector +0 -3
  405. data/test/stub/rails_apps/2.3/mycook/script/process/reaper +0 -3
  406. data/test/stub/rails_apps/2.3/mycook/script/process/spawner +0 -3
  407. data/test/stub/rails_apps/2.3/mycook/script/runner +0 -3
  408. data/test/stub/rails_apps/2.3/mycook/script/server +0 -3
  409. data/test/stub/wsgi/public/wsgi-snake.jpg +0 -0
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  # Phusion Passenger - https://www.phusionpassenger.com/
2
3
  # Copyright (c) 2010-2013 Phusion
3
4
  #
@@ -22,7 +23,7 @@
22
23
  # THE SOFTWARE.
23
24
 
24
25
  require 'erb'
25
- require 'phusion_passenger/utils/ansi_colors'
26
+ PhusionPassenger.require_passenger_lib 'utils/ansi_colors'
26
27
 
27
28
  module PhusionPassenger
28
29
 
@@ -21,8 +21,6 @@
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
23
 
24
- require 'phusion_passenger'
25
-
26
24
  module PhusionPassenger
27
25
  PASSENGER_ANALYTICS_WEB_LOG = "PASSENGER_ANALYTICS_WEB_LOG".freeze
28
26
  PASSENGER_TXN_ID = "PASSENGER_TXN_ID".freeze
@@ -74,6 +72,13 @@ module PhusionPassenger
74
72
  NGINX_DOC_URL = "http://www.modrails.com/documentation/Users%20guide%20Nginx.html"
75
73
  STANDALONE_DOC_URL = "http://www.modrails.com/documentation/Users%20guide%20Standalone.html"
76
74
  SUPPORT_URL = "http://www.phusionpassenger.com/support"
75
+ ENTERPRISE_URL = "http://www.phusionpassenger.com/enterprise"
76
+ DEB_DEV_PACKAGE = "passenger-dev"
77
+ DEB_APACHE_MODULE_PACKAGE = "libapache2-mod-passenger"
78
+ DEB_NGINX_PACKAGE = "nginx-extras"
79
+ RPM_DEV_PACKAGE = "passenger-devel"
80
+ RPM_APACHE_MODULE_PACKAGE = "mod_passenger"
81
+ RPM_NGINX_PACKAGE = "nginx"
77
82
  STANDALONE_NGINX_CONFIGURE_OPTIONS =
78
83
  "--with-cc-opt='-Wno-error' " <<
79
84
  "--without-http_fastcgi_module " <<
@@ -22,8 +22,8 @@
22
22
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
23
  # THE SOFTWARE.
24
24
 
25
- require 'phusion_passenger/public_api'
26
- require 'phusion_passenger/debug_logging'
25
+ PhusionPassenger.require_passenger_lib 'public_api'
26
+ PhusionPassenger.require_passenger_lib 'debug_logging'
27
27
 
28
28
  module PhusionPassenger
29
29
 
@@ -42,6 +42,8 @@ module LoaderSharedHelpers
42
42
  # To be called whenever the (pre)loader is about to abort with an error.
43
43
  def about_to_abort(exception = nil)
44
44
  dump_all_information
45
+ # https://code.google.com/p/phusion-passenger/issues/detail?id=1039
46
+ puts
45
47
  end
46
48
 
47
49
  def to_boolean(value)
@@ -152,7 +154,7 @@ module LoaderSharedHelpers
152
154
  DebugLogging.log_level = options["log_level"] if options["log_level"]
153
155
 
154
156
  # Instantiate the analytics logger if requested. Can be nil.
155
- require 'phusion_passenger/analytics_logger'
157
+ PhusionPassenger.require_passenger_lib 'analytics_logger'
156
158
  options["analytics_logger"] = AnalyticsLogger.new_from_options(options)
157
159
  end
158
160
 
@@ -220,15 +222,6 @@ module LoaderSharedHelpers
220
222
  end
221
223
  end
222
224
 
223
- # Bundler might remove Phusion Passenger from the load path in its zealous
224
- # attempt to un-require RubyGems, so here we put Phusion Passenger back
225
- # into the load path. This must be done before loading the app's startup
226
- # file because the app might require() Phusion Passenger files.
227
- if !$LOAD_PATH.include?(PhusionPassenger.ruby_libdir)
228
- $LOAD_PATH.unshift(PhusionPassenger.ruby_libdir)
229
- $LOAD_PATH.uniq!
230
- end
231
-
232
225
 
233
226
  # !!! NOTE !!!
234
227
  # If the app is using Bundler then any dependencies required past this
@@ -242,15 +235,6 @@ module LoaderSharedHelpers
242
235
  # This method is to be called after loading the application code but
243
236
  # before forking a worker process.
244
237
  def after_loading_app_code(options)
245
- # Even though run_load_path_setup_code() restores the Phusion Passenger
246
- # load path after setting up Bundler, the app itself might also
247
- # remove Phusion Passenger from the load path for whatever reason,
248
- # so here we restore the load path again.
249
- if !$LOAD_PATH.include?(PhusionPassenger.ruby_libdir)
250
- $LOAD_PATH.unshift(PhusionPassenger.ruby_libdir)
251
- $LOAD_PATH.uniq!
252
- end
253
-
254
238
  # Post-install framework extensions. Possibly preceded by a call to
255
239
  # PhusionPassenger.install_framework_extensions!
256
240
  if defined?(::Rails) && !defined?(::Rails::VERSION)
@@ -268,6 +252,13 @@ module LoaderSharedHelpers
268
252
  end
269
253
  end
270
254
 
255
+ def advertise_readiness
256
+ # https://code.google.com/p/phusion-passenger/issues/detail?id=1039
257
+ puts
258
+
259
+ puts "!> Ready"
260
+ end
261
+
271
262
  def advertise_sockets(output, request_handler)
272
263
  request_handler.server_sockets.each_pair do |name, options|
273
264
  concurrency = PhusionPassenger.advertised_concurrency_level || options[:concurrency]
@@ -23,9 +23,9 @@
23
23
  # THE SOFTWARE.
24
24
 
25
25
  require 'socket'
26
- require 'phusion_passenger/message_channel'
27
- require 'phusion_passenger/utils'
28
- require 'phusion_passenger/utils/tmpdir'
26
+ PhusionPassenger.require_passenger_lib 'message_channel'
27
+ PhusionPassenger.require_passenger_lib 'utils'
28
+ PhusionPassenger.require_passenger_lib 'utils/tmpdir'
29
29
 
30
30
  module PhusionPassenger
31
31
 
@@ -112,7 +112,18 @@ class MessageClient
112
112
  check_security_response
113
113
  return read_scalar
114
114
  end
115
-
115
+
116
+ def restart_app_group(app_group_name, options = {})
117
+ write("restart_app_group", app_group_name, *options.to_a.flatten)
118
+ check_security_response
119
+ result = read
120
+ if result.nil?
121
+ raise EOFError
122
+ else
123
+ return result.first == "true"
124
+ end
125
+ end
126
+
116
127
  def helper_agent_requests
117
128
  write("requests")
118
129
  check_security_response
@@ -32,29 +32,36 @@ class NativeSupportLoader
32
32
  if defined?(NativeSupport)
33
33
  return true
34
34
  else
35
- require 'phusion_passenger'
36
35
  load_from_native_support_output_dir ||
37
- load_from_source_root ||
36
+ load_from_buildout_dir ||
38
37
  load_from_load_path ||
39
38
  load_from_home_dir
40
39
  end
41
40
  end
42
41
 
43
42
  def start
44
- try_load || download_binary_and_load || compile_and_load
43
+ if try_load
44
+ return true
45
+ elsif download_binary_and_load || compile_and_load
46
+ STDERR.puts " --> #{library_name} successfully loaded."
47
+ return true
48
+ else
49
+ STDERR.puts " --> Continuing without #{library_name}."
50
+ return false
51
+ end
45
52
  end
46
53
 
47
54
  private
48
55
  def archdir
49
56
  @archdir ||= begin
50
- require 'phusion_passenger/platform_info/binary_compatibility'
57
+ PhusionPassenger.require_passenger_lib 'platform_info/binary_compatibility'
51
58
  PlatformInfo.ruby_extension_binary_compatibility_id
52
59
  end
53
60
  end
54
61
 
55
62
  def libext
56
63
  @libext ||= begin
57
- require 'phusion_passenger/platform_info/operating_system'
64
+ PhusionPassenger.require_passenger_lib 'platform_info/operating_system'
58
65
  PlatformInfo.library_extension
59
66
  end
60
67
  end
@@ -74,23 +81,13 @@ private
74
81
  File.join(PhusionPassenger.ruby_extension_source_dir, "extconf.rb")
75
82
  end
76
83
 
77
- def native_support_dir_in_source_root
78
- if PhusionPassenger.originally_packaged?
79
- @native_support_dir_in_source_root ||=
80
- File.expand_path("#{PhusionPassenger.source_root}/buildout/ruby")
81
- else
82
- return nil
83
- end
84
- end
85
-
86
84
  def load_from_native_support_output_dir
87
85
  # Quick workaround for people suffering from
88
86
  # https://code.google.com/p/phusion-passenger/issues/detail?id=865
89
87
  output_dir = ENV['PASSENGER_NATIVE_SUPPORT_OUTPUT_DIR']
90
88
  if output_dir && !output_dir.empty?
91
89
  begin
92
- require "#{output_dir}/#{VERSION_STRING}/#{archdir}/#{library_name}"
93
- return true
90
+ return load_native_extension("#{output_dir}/#{VERSION_STRING}/#{archdir}/#{library_name}")
94
91
  rescue LoadError
95
92
  return false
96
93
  end
@@ -99,11 +96,10 @@ private
99
96
  end
100
97
  end
101
98
 
102
- def load_from_source_root
103
- if PhusionPassenger.originally_packaged?
99
+ def load_from_buildout_dir
100
+ if PhusionPassenger.buildout_dir
104
101
  begin
105
- require "#{native_support_dir_in_source_root}/#{archdir}/#{library_name}"
106
- return true
102
+ return load_native_extension("#{PhusionPassenger.buildout_dir}/ruby/#{archdir}/#{library_name}")
107
103
  rescue LoadError
108
104
  return false
109
105
  end
@@ -113,16 +109,14 @@ private
113
109
  end
114
110
 
115
111
  def load_from_load_path
116
- require 'passenger_native_support'
117
- return true
112
+ return load_native_extension('passenger_native_support')
118
113
  rescue LoadError
119
114
  return false
120
115
  end
121
116
 
122
117
  def load_from_home_dir
123
118
  begin
124
- require "#{home}/#{USER_NAMESPACE_DIRNAME}/native_support/#{VERSION_STRING}/#{archdir}/#{library_name}"
125
- return true
119
+ return load_native_extension("#{home}/#{USER_NAMESPACE_DIRNAME}/native_support/#{VERSION_STRING}/#{archdir}/#{library_name}")
126
120
  rescue LoadError
127
121
  return false
128
122
  end
@@ -133,16 +127,18 @@ private
133
127
  return
134
128
  end
135
129
  if ENV['PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY'] == '0'
136
- STDERR.puts "*** Phusion Passenger: PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY set, " +
137
- "not downloading precompiled binary"
130
+ STDERR.puts " --> Skipping downloading of precompiled #{library_name}"
138
131
  return
139
132
  end
140
- STDERR.puts "*** Phusion Passenger: no #{library_name} found for " +
141
- "the current Ruby interpreter. Downloading precompiled binary from the Phusion server " +
142
- "(set PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY=0 to disable)..."
133
+
134
+ STDERR.puts " --> Downloading precompiled #{library_name} for the current Ruby interpreter..."
135
+ STDERR.puts " (set PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY=0 to disable)"
143
136
 
144
- require 'phusion_passenger/platform_info/ruby'
145
- require 'phusion_passenger/utils/tmpio'
137
+ require 'shellwords'
138
+ require 'logger'
139
+ PhusionPassenger.require_passenger_lib 'platform_info/ruby'
140
+ PhusionPassenger.require_passenger_lib 'utils/tmpio'
141
+ PhusionPassenger.require_passenger_lib 'utils/download'
146
142
  PhusionPassenger::Utils.mktmpdir("passenger-native-support-") do |dir|
147
143
  Dir.chdir(dir) do
148
144
  basename = "rubyext-#{archdir}.tar.gz"
@@ -150,9 +146,10 @@ private
150
146
  return false
151
147
  end
152
148
 
153
- sh "tar", "xzf", basename
154
- sh "rm", "-f", basename
155
- STDERR.puts "Checking whether downloaded binary is usable..."
149
+ s_basename = Shellwords.escape(basename)
150
+ sh "tar xzf #{s_basename}"
151
+ sh "rm -f #{s_basename}"
152
+ STDERR.puts " Checking whether downloaded binary is usable..."
156
153
 
157
154
  File.open("test.rb", "w") do |f|
158
155
  f.puts(%Q{
@@ -165,19 +162,19 @@ private
165
162
  if sh_nonfatal("#{PlatformInfo.ruby_command} -I. test.rb") &&
166
163
  File.exist?("test.txt") &&
167
164
  File.read("test.txt") == "hello\n"
168
- STDERR.puts "Binary is usable."
165
+ STDERR.puts " Binary is usable."
169
166
  File.unlink("test.rb")
170
167
  File.unlink("test.txt")
171
168
  result = try_directories(installation_target_dirs) do |target_dir|
172
169
  files = Dir["#{dir}/*"]
173
- STDERR.puts "# Installing " + files.map{ |n| File.basename(n) }.join(' ')
170
+ STDERR.puts " Installing " + files.map{ |n| File.basename(n) }.join(' ')
174
171
  FileUtils.cp(files, target_dir)
175
- require "#{target_dir}/#{library_name}"
176
- [true, false]
172
+ load_result = load_native_extension("#{target_dir}/#{library_name}")
173
+ [load_result, false]
177
174
  end
178
175
  return result
179
176
  else
180
- STDERR.puts "Binary is not usable."
177
+ STDERR.puts " Binary is not usable."
181
178
  return false
182
179
  end
183
180
  end
@@ -186,23 +183,41 @@ private
186
183
 
187
184
  def compile_and_load
188
185
  if ENV['PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY'] == '0'
189
- STDERR.puts "*** Phusion Passenger: PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY set, " +
190
- "not compiling native_support"
186
+ STDERR.puts " --> Skipping compiling of #{library_name}"
187
+ return false
188
+ end
189
+
190
+ if PhusionPassenger.natively_packaged? && !File.exist?(PhusionPassenger.ruby_extension_source_dir)
191
+ PhusionPassenger.require_passenger_lib 'constants'
192
+ STDERR.puts " --> No #{library_name} found for current Ruby interpreter."
193
+ case PhusionPassenger.native_packaging_method
194
+ when 'deb'
195
+ STDERR.puts " This library provides various optimized routines that make"
196
+ STDERR.puts " #{PhusionPassenger::PROGRAM_NAME} faster. Please run 'sudo apt-get install #{PhusionPassenger::DEB_DEV_PACKAGE}'"
197
+ STDERR.puts " so that #{PhusionPassenger::PROGRAM_NAME} can compile one on the next run."
198
+ when 'rpm'
199
+ STDERR.puts " This library provides various optimized routines that make"
200
+ STDERR.puts " #{PhusionPassenger::PROGRAM_NAME} faster. Please run 'sudo yum install #{PhusionPassenger::RPM_DEV_PACKAGE}'"
201
+ STDERR.puts " so that #{PhusionPassenger::PROGRAM_NAME} can compile one on the next run."
202
+ else
203
+ STDERR.puts " #{PhusionPassenger::PROGRAM_NAME} can compile one, but an extra package must be installed"
204
+ STDERR.puts " first. Please ask your operating system vendor for instructions."
205
+ end
191
206
  return false
192
207
  end
193
208
 
194
- STDERR.puts "*** Phusion Passenger: no #{library_name} found for " +
195
- "the current Ruby interpreter. Compiling one (set " +
196
- "PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY=0 to disable)..."
209
+ STDERR.puts " --> Compiling #{library_name} for the current Ruby interpreter..."
210
+ STDERR.puts " (set PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY=0 to disable)"
211
+ STDERR.puts " -------------------------------"
197
212
 
198
213
  require 'fileutils'
199
- require 'phusion_passenger/platform_info/ruby'
214
+ require 'shellwords'
215
+ PhusionPassenger.require_passenger_lib 'platform_info/ruby'
200
216
 
201
217
  target_dir = compile(installation_target_dirs)
202
218
  if target_dir
203
- require "#{target_dir}/#{library_name}"
219
+ return load_native_extension("#{target_dir}/#{library_name}")
204
220
  else
205
- STDERR.puts "Ruby native_support extension not loaded. Continuing without native_support."
206
221
  return false
207
222
  end
208
223
  end
@@ -212,8 +227,8 @@ private
212
227
  if (output_dir = ENV['PASSENGER_NATIVE_SUPPORT_OUTPUT_DIR']) && !output_dir.empty?
213
228
  target_dirs << "#{output_dir}/#{VERSION_STRING}/#{archdir}"
214
229
  end
215
- if native_support_dir_in_source_root
216
- target_dirs << "#{native_support_dir_in_source_root}/#{archdir}"
230
+ if PhusionPassenger.buildout_dir
231
+ target_dirs << "#{PhusionPassenger.buildout_dir}/ruby/#{archdir}"
217
232
  end
218
233
  target_dirs << "#{home}/#{USER_NAMESPACE_DIRNAME}/native_support/#{VERSION_STRING}/#{archdir}"
219
234
  return target_dirs
@@ -222,62 +237,49 @@ private
222
237
  def download(name, output_dir)
223
238
  url = "#{PhusionPassenger::BINARIES_URL_ROOT}/#{PhusionPassenger::VERSION_STRING}/#{name}"
224
239
  filename = "#{output_dir}/#{name}"
225
-
226
- cache_dir = PhusionPassenger.download_cache_dir
227
- if File.exist?("#{cache_dir}/#{name}")
228
- FileUtils.cp("#{cache_dir}/#{name}", filename, :verbose => true)
229
- return true
230
- end
231
-
232
- STDERR.puts "Attempting to download #{url} into #{output_dir}"
233
- cert = PhusionPassenger.binaries_ca_cert_path
234
- File.unlink("#{filename}.tmp") rescue nil
235
- if PhusionPassenger::PlatformInfo.find_command("wget")
236
- result = system("wget", "--tries=3", "-O", "#{filename}.tmp", "--ca-certificate=#{cert}", url)
237
- else
238
- result = system("curl", url, "-f", "-L", "-o", "#{filename}.tmp", "--cacert", cert)
239
- end
240
- if result
241
- File.rename("#{filename}.tmp", filename)
242
- else
243
- File.unlink("#{filename}.tmp") rescue nil
244
- end
245
- return result
240
+ logger = Logger.new(STDERR)
241
+ logger.level = Logger::WARN
242
+ logger.formatter = proc { |severity, datetime, progname, msg| " #{msg}\n" }
243
+ return PhusionPassenger::Utils::Download.download(url, filename,
244
+ :cacert => PhusionPassenger.binaries_ca_cert_path,
245
+ :use_cache => true,
246
+ :logger => logger)
246
247
  end
247
248
 
248
249
  def mkdir(dir)
249
250
  begin
250
- STDERR.puts "# mkdir -p #{dir}"
251
+ STDERR.puts " # mkdir -p #{dir}"
251
252
  FileUtils.mkdir_p(dir)
252
253
  rescue Errno::EEXIST
253
254
  end
254
255
  end
255
256
 
256
- def sh(*args)
257
- if !sh_nonfatal(*args)
258
- command_string = args.join(' ')
257
+ def sh(command_string)
258
+ if !sh_nonfatal(command_string)
259
259
  raise "Could not compile #{library_name} (\"#{command_string}\" failed)"
260
260
  end
261
261
  end
262
262
 
263
- def sh_nonfatal(*args)
264
- command_string = args.join(' ')
265
- STDERR.puts "# #{command_string}"
266
- return system(*args)
263
+ def sh_nonfatal(command_string)
264
+ STDERR.puts " # #{command_string}"
265
+ PhusionPassenger::Utils.mktmpdir("passenger-native-support-") do |tmpdir|
266
+ s_tmpdir = Shellwords.escape(tmpdir)
267
+ result = system("#{command_string} >#{s_tmpdir}/log 2>&1")
268
+ system("cat #{s_tmpdir}/log | sed 's/^/ /'")
269
+ return result
270
+ end
267
271
  end
268
272
 
269
273
  def compile(target_dirs)
270
274
  try_directories(target_dirs) do |target_dir|
271
275
  result =
272
- sh_nonfatal("#{PlatformInfo.ruby_command} '#{extconf_rb}'") &&
273
- sh_nonfatal("make")
276
+ sh_nonfatal("#{PlatformInfo.ruby_command} #{Shellwords.escape extconf_rb}") &&
277
+ sh_nonfatal("make clean && make")
274
278
  if result
275
- STDERR.puts "Compilation succesful."
276
- STDERR.puts "-------------------------------"
279
+ STDERR.puts " Compilation succesful."
277
280
  [target_dir, false]
278
281
  else
279
- STDERR.puts "Compilation failed."
280
- STDERR.puts "-------------------------------"
282
+ STDERR.puts " Compilation failed."
281
283
  [nil, false]
282
284
  end
283
285
  end
@@ -290,7 +292,7 @@ private
290
292
  mkdir(dir)
291
293
  File.open("#{dir}/.permission_test", "w").close
292
294
  File.unlink("#{dir}/.permission_test")
293
- STDERR.puts "# cd #{dir}"
295
+ STDERR.puts " # cd #{dir}"
294
296
  Dir.chdir(dir) do
295
297
  result, should_retry = yield(dir)
296
298
  return result if !should_retry
@@ -301,33 +303,49 @@ private
301
303
  # error on the last one too then propagate the
302
304
  # exception.
303
305
  if i == dirs.size - 1
304
- STDERR.puts "Encountered permission error, " +
306
+ STDERR.puts " Encountered permission error, " +
305
307
  "but no more directories to try. Giving up."
306
- STDERR.puts "-------------------------------"
308
+ STDERR.puts " -------------------------------"
307
309
  return nil
308
310
  else
309
- STDERR.puts "Encountered permission error, " +
311
+ STDERR.puts " Encountered permission error, " +
310
312
  "trying a different directory..."
311
- STDERR.puts "-------------------------------"
313
+ STDERR.puts " -------------------------------"
312
314
  end
313
315
  rescue Errno::ENOTDIR
314
- # This can occur when PhusionPassenger.source_root
315
- # is a location configuration file, and natively_packaged
316
- # is set to false. For example, when we're running
317
- # in Phusion Passenger Standalone. In this case
318
- # just ignore this directory.
316
+ # This can occur when locations.ini set buildout_dir
317
+ # to an invalid path. Just ignore this error.
319
318
  if i == dirs.size - 1
320
- STDERR.puts "Not a valid directory, " +
319
+ STDERR.puts " Not a valid directory, " +
321
320
  "but no more directories to try. Giving up."
322
- STDERR.puts "-------------------------------"
321
+ STDERR.puts " -------------------------------"
323
322
  return nil
324
323
  else
325
- STDERR.puts "Not a valid directory. Trying a different one..."
326
- STDERR.puts "-------------------------------"
324
+ STDERR.puts " Not a valid directory. Trying a different one..."
325
+ STDERR.puts " -------------------------------"
327
326
  end
328
327
  end
329
328
  end
330
329
  end
330
+
331
+ def load_native_extension(name_or_filename)
332
+ # If passenger_native_support.so exited because it detected that it was compiled
333
+ # for a different Ruby version, then subsequent require("passenger_native_support")
334
+ # calls will do nothing. So we remove passenger_native_support from $LOADED_FEATURES
335
+ # to force it to be loaded.
336
+ $LOADED_FEATURES.reject! { |fn| File.basename(fn) == library_name }
337
+ begin
338
+ require(name_or_filename)
339
+ return defined?(PhusionPassenger::NativeSupport)
340
+ rescue LoadError => e
341
+ if e.to_s =~ /dlopen/
342
+ # Print dlopen failures. We're not interested in any other
343
+ # kinds of failures, such as file-not-found.
344
+ puts e.to_s.gsub(/^/, " ")
345
+ end
346
+ return false
347
+ end
348
+ end
331
349
  end
332
350
 
333
351
  end # module PhusionPassenger