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
@@ -37,7 +37,7 @@ if (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby") && RUBY_VERSION < "1.8.7"
37
37
  "gem install fastthread"
38
38
  end
39
39
  end
40
- require 'phusion_passenger/native_support'
40
+ PhusionPassenger.require_passenger_lib 'native_support'
41
41
 
42
42
  class Exception
43
43
  def backtrace_string(current_location = nil)
@@ -20,7 +20,7 @@
20
20
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
- require 'phusion_passenger/utils/file_system_watcher'
23
+ PhusionPassenger.require_passenger_lib 'utils/file_system_watcher'
24
24
 
25
25
  module PhusionPassenger
26
26
  module Standalone
@@ -137,7 +137,7 @@ private
137
137
  end
138
138
 
139
139
  def load_config_file!(context, filename)
140
- require 'phusion_passenger/utils/json' if !defined?(PhusionPassenger::Utils::JSON)
140
+ PhusionPassenger.require_passenger_lib 'utils/json' if !defined?(PhusionPassenger::Utils::JSON)
141
141
  begin
142
142
  data = File.open(filename, "r:utf-8") do |f|
143
143
  f.read
@@ -21,9 +21,8 @@
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
23
  require 'optparse'
24
- require 'phusion_passenger'
25
- require 'phusion_passenger/constants'
26
- require 'phusion_passenger/standalone/utils'
24
+ PhusionPassenger.require_passenger_lib 'constants'
25
+ PhusionPassenger.require_passenger_lib 'standalone/utils'
27
26
 
28
27
  module PhusionPassenger
29
28
  module Standalone
@@ -94,7 +93,7 @@ private
94
93
  end
95
94
 
96
95
  def require_app_finder
97
- require 'phusion_passenger/standalone/app_finder' unless defined?(AppFinder)
96
+ PhusionPassenger.require_passenger_lib 'standalone/app_finder' unless defined?(AppFinder)
98
97
  end
99
98
 
100
99
  def debugging?
@@ -106,7 +105,7 @@ private
106
105
 
107
106
  global_config_file = File.join(ENV['HOME'], USER_NAMESPACE_DIRNAME, "standalone", "config")
108
107
  if File.exist?(global_config_file)
109
- require 'phusion_passenger/standalone/config_file' unless defined?(ConfigFile)
108
+ PhusionPassenger.require_passenger_lib 'standalone/config_file' unless defined?(ConfigFile)
110
109
  global_options = ConfigFile.new(:global_config, global_config_file).options
111
110
  @options.merge!(global_options)
112
111
  end
@@ -182,8 +181,8 @@ private
182
181
  end
183
182
 
184
183
  def write_nginx_config_file
185
- require 'phusion_passenger/platform_info/ruby'
186
- require 'phusion_passenger/utils/tmpio'
184
+ PhusionPassenger.require_passenger_lib 'platform_info/ruby'
185
+ PhusionPassenger.require_passenger_lib 'utils/tmpio'
187
186
  @temp_dir = PhusionPassenger::Utils.mktmpdir(
188
187
  "passenger-standalone.")
189
188
  @config_filename = "#{@temp_dir}/config"
@@ -198,7 +197,10 @@ private
198
197
 
199
198
  File.open(location_config_filename, 'w') do |f|
200
199
  f.puts '[locations]'
201
- f.puts "natively_packaged=false"
200
+ f.puts "natively_packaged=#{PhusionPassenger.natively_packaged?}"
201
+ if PhusionPassenger.natively_packaged?
202
+ f.puts "native_packaging_method=#{PhusionPassenger.native_packaging_method}"
203
+ end
202
204
  f.puts "lib_dir=#{@runtime_locator.find_lib_dir}"
203
205
  f.puts "agents_dir=#{@runtime_locator.find_agents_dir}"
204
206
  locations_ini_fields.each do |field|
@@ -20,7 +20,7 @@
20
20
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
- require 'phusion_passenger/standalone/command'
23
+ PhusionPassenger.require_passenger_lib 'standalone/command'
24
24
 
25
25
  module PhusionPassenger
26
26
  module Standalone
@@ -20,7 +20,7 @@
20
20
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
- require 'phusion_passenger/standalone/command'
23
+ PhusionPassenger.require_passenger_lib 'standalone/command'
24
24
 
25
25
  module PhusionPassenger
26
26
  module Standalone
@@ -43,7 +43,7 @@ class Main
43
43
  COMMANDS.each do |command_spec|
44
44
  command_name = command_spec[0]
45
45
  filename = command_name.sub(/-/, '_') + "_command"
46
- require "phusion_passenger/standalone/#{filename}"
46
+ PhusionPassenger.require_passenger_lib "standalone/#{filename}"
47
47
  command_class = Standalone.const_get(command_spec[1])
48
48
  yield(command_name, command_class)
49
49
  end
@@ -107,7 +107,7 @@ private
107
107
  def get_command_class(spec)
108
108
  command_name, class_name = spec
109
109
  filename = command_name.sub(/-/, '_') + "_command"
110
- require "phusion_passenger/standalone/#{filename}"
110
+ PhusionPassenger.require_passenger_lib("standalone/#{filename}")
111
111
  return Standalone.const_get(class_name)
112
112
  end
113
113
  end
@@ -31,8 +31,8 @@ class PackageRuntimeCommand < Command
31
31
  end
32
32
 
33
33
  def self.require_libs
34
- require 'phusion_passenger/platform_info/binary_compatibility'
35
- require 'phusion_passenger/standalone/runtime_installer'
34
+ PhusionPassenger.require_passenger_lib 'platform_info/binary_compatibility'
35
+ PhusionPassenger.require_passenger_lib 'standalone/runtime_installer'
36
36
  end
37
37
 
38
38
  def run
@@ -23,15 +23,16 @@
23
23
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
24
  # THE SOFTWARE.
25
25
  require 'fileutils'
26
- require 'phusion_passenger'
27
- require 'phusion_passenger/abstract_installer'
28
- require 'phusion_passenger/packaging'
29
- require 'phusion_passenger/common_library'
30
- require 'phusion_passenger/platform_info'
31
- require 'phusion_passenger/platform_info/ruby'
32
- require 'phusion_passenger/platform_info/binary_compatibility'
33
- require 'phusion_passenger/standalone/utils'
34
- require 'phusion_passenger/utils/tmpio'
26
+ require 'logger'
27
+ PhusionPassenger.require_passenger_lib 'constants'
28
+ PhusionPassenger.require_passenger_lib 'abstract_installer'
29
+ PhusionPassenger.require_passenger_lib 'packaging'
30
+ PhusionPassenger.require_passenger_lib 'common_library'
31
+ PhusionPassenger.require_passenger_lib 'platform_info'
32
+ PhusionPassenger.require_passenger_lib 'platform_info/ruby'
33
+ PhusionPassenger.require_passenger_lib 'platform_info/binary_compatibility'
34
+ PhusionPassenger.require_passenger_lib 'standalone/utils'
35
+ PhusionPassenger.require_passenger_lib 'utils/tmpio'
35
36
 
36
37
  module PhusionPassenger
37
38
  module Standalone
@@ -146,7 +147,7 @@ protected
146
147
 
147
148
  private
148
149
  def check_for_download_tool
149
- require 'phusion_passenger/platform_info/depcheck'
150
+ PhusionPassenger.require_passenger_lib 'platform_info/depcheck'
150
151
  PlatformInfo::Depcheck.load('depcheck_specs/utilities')
151
152
  result = PlatformInfo::Depcheck.find('download-tool').check
152
153
  # Don't output anything if there is a download tool.
@@ -189,6 +190,7 @@ private
189
190
  "because --no-compile-runtime is given."
190
191
  exit(1)
191
192
  end
193
+ check_nginx_module_sources_available || exit(1)
192
194
  puts
193
195
  check_dependencies(false) || exit(1)
194
196
  puts
@@ -278,8 +280,15 @@ private
278
280
  basename = "webhelper-#{@nginx_version}-#{PlatformInfo.cxx_binary_compatibility_id}.tar.gz"
279
281
  url = "#{@binaries_url_root}/#{PhusionPassenger::VERSION_STRING}/#{basename}"
280
282
  tarball = "#{@working_dir}/#{basename}"
281
- if !download(url, tarball, :cacert => PhusionPassenger.binaries_ca_cert_path, :use_cache => true)
282
- puts " No binary are available for your platform. Will compile them from source"
283
+ logger = Logger.new(STDOUT)
284
+ logger.level = Logger::WARN
285
+ logger.formatter = proc { |severity, datetime, progname, msg| " #{msg}\n" }
286
+ result = download(url, tarball,
287
+ :cacert => PhusionPassenger.binaries_ca_cert_path,
288
+ :use_cache => true,
289
+ :logger => logger)
290
+ if !result
291
+ puts " No binary is available for your platform. Will compile it from source."
283
292
  return false
284
293
  end
285
294
 
@@ -406,6 +415,39 @@ private
406
415
  puts
407
416
  end
408
417
 
418
+ def check_nginx_module_sources_available
419
+ if PhusionPassenger.natively_packaged? && !File.exist?(PhusionPassenger.nginx_module_source_dir)
420
+ case PhusionPassenger.native_packaging_method
421
+ when "deb"
422
+ command = "sudo sh -c 'apt-get update && apt-get install #{DEB_DEV_PACKAGE}'"
423
+ when "rpm"
424
+ command = "sudo yum install #{RPM_DEV_PACKAGE}"
425
+ end
426
+ if command
427
+ if STDIN.tty?
428
+ puts " --> Installing #{PhusionPassenger::PROGRAM_NAME} web helper sources"
429
+ puts " Running: #{command}"
430
+ if system(command)
431
+ return true
432
+ else
433
+ puts " <red>*** Command failed: #{command}</red>"
434
+ return false
435
+ end
436
+ else
437
+ puts " --> #{PhusionPassenger::PROGRAM_NAME} web helper sources not installed"
438
+ puts " Please install them first: #{command}"
439
+ return false
440
+ end
441
+ else
442
+ puts " --> #{PhusionPassenger::PROGRAM_NAME} web helper sources not installed"
443
+ puts " <red>Please ask your operating system vendor how to install these.</red>"
444
+ return false
445
+ end
446
+ else
447
+ return true
448
+ end
449
+ end
450
+
409
451
  def check_whether_we_can_write_to(dir)
410
452
  FileUtils.mkdir_p(dir)
411
453
  File.new("#{dir}/__test__.txt", "w").close
@@ -563,7 +605,7 @@ private
563
605
  end
564
606
 
565
607
  def install_nginx_from_source(source_dir)
566
- require 'phusion_passenger/platform_info/compiler'
608
+ PhusionPassenger.require_passenger_lib 'platform_info/compiler'
567
609
  Dir.chdir(source_dir) do
568
610
  shell = PlatformInfo.find_command('bash') || "sh"
569
611
  command = ""
@@ -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/platform_info/binary_compatibility'
26
- require 'phusion_passenger/utils/json'
25
+ PhusionPassenger.require_passenger_lib 'platform_info/binary_compatibility'
26
+ PhusionPassenger.require_passenger_lib 'utils/json'
27
27
  require 'etc'
28
28
 
29
29
  module PhusionPassenger
@@ -55,7 +55,7 @@ class RuntimeLocator
55
55
 
56
56
  if PhusionPassenger.originally_packaged?
57
57
  if debugging?
58
- @support_dir = "#{PhusionPassenger.source_root}/buildout"
58
+ @support_dir = PhusionPassenger.buildout_dir
59
59
  else
60
60
  dir = "#{@runtime_dir}/#{version}/support-#{cxx_compat_id}"
61
61
  if self.class.looks_like_support_dir?(dir)
@@ -23,10 +23,9 @@
23
23
  require 'socket'
24
24
  require 'thread'
25
25
  require 'etc'
26
- require 'phusion_passenger'
27
- require 'phusion_passenger/plugin'
28
- require 'phusion_passenger/standalone/command'
29
- require 'phusion_passenger/platform_info/operating_system'
26
+ PhusionPassenger.require_passenger_lib 'plugin'
27
+ PhusionPassenger.require_passenger_lib 'standalone/command'
28
+ PhusionPassenger.require_passenger_lib 'platform_info/operating_system'
30
29
 
31
30
  # We lazy load as many libraries as possible not only to improve startup performance,
32
31
  # but also to ensure that we don't require libraries before we've passed the dependency
@@ -53,7 +52,7 @@ class StartCommand < Command
53
52
  parse_my_options
54
53
  sanity_check_options
55
54
 
56
- require 'phusion_passenger/standalone/runtime_locator'
55
+ PhusionPassenger.require_passenger_lib 'standalone/runtime_locator'
57
56
  @runtime_locator = RuntimeLocator.new(@options[:runtime_dir],
58
57
  @options[:nginx_version])
59
58
  ensure_runtime_installed
@@ -321,7 +320,7 @@ private
321
320
  begin
322
321
  TCPServer.new('127.0.0.1', @options[:port]).close
323
322
  rescue Errno::EACCES
324
- require 'phusion_passenger/platform_info/ruby'
323
+ PhusionPassenger.require_passenger_lib 'platform_info/ruby'
325
324
  myself = `whoami`.strip
326
325
  error "Only the 'root' user can run this program on port #{@options[:port]}. " <<
327
326
  "You are currently running as '#{myself}'. Please re-run this program " <<
@@ -450,7 +449,7 @@ private
450
449
  end
451
450
 
452
451
  def install_runtime(runtime_locator)
453
- require 'phusion_passenger/standalone/runtime_installer'
452
+ PhusionPassenger.require_passenger_lib 'standalone/runtime_installer'
454
453
  installer = RuntimeInstaller.new(
455
454
  :targets => runtime_locator.install_targets,
456
455
  :support_dir => runtime_locator.support_dir_install_destination,
@@ -20,7 +20,7 @@
20
20
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
- require 'phusion_passenger/standalone/command'
23
+ PhusionPassenger.require_passenger_lib 'standalone/command'
24
24
 
25
25
  module PhusionPassenger
26
26
  module Standalone
@@ -20,7 +20,7 @@
20
20
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
- require 'phusion_passenger/standalone/command'
23
+ PhusionPassenger.require_passenger_lib 'standalone/command'
24
24
 
25
25
  module PhusionPassenger
26
26
  module Standalone
@@ -28,7 +28,7 @@ module Utils
28
28
  private
29
29
  def require_platform_info_binary_compatibility
30
30
  if !defined?(PlatformInfo) || !PlatformInfo.respond_to?(:cxx_binary_compatibility_id)
31
- require 'phusion_passenger/platform_info/binary_compatibility'
31
+ PhusionPassenger.require_passenger_lib 'platform_info/binary_compatibility'
32
32
  end
33
33
  end
34
34
 
@@ -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
  #
@@ -20,8 +20,7 @@
20
20
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
- require 'phusion_passenger'
24
- require 'phusion_passenger/standalone/command'
23
+ PhusionPassenger.require_passenger_lib 'standalone/command'
25
24
 
26
25
  module PhusionPassenger
27
26
  module Standalone
@@ -26,7 +26,7 @@ begin
26
26
  require 'rubygems'
27
27
  rescue LoadError
28
28
  end
29
- require 'phusion_passenger/native_support'
29
+ PhusionPassenger.require_passenger_lib 'native_support'
30
30
 
31
31
  module PhusionPassenger
32
32
 
@@ -22,8 +22,7 @@
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'
26
- require 'phusion_passenger/platform_info'
25
+ PhusionPassenger.require_passenger_lib 'platform_info'
27
26
  require 'fileutils'
28
27
  require 'shellwords'
29
28
 
@@ -21,7 +21,7 @@
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/native_support'
24
+ PhusionPassenger.require_passenger_lib 'native_support'
25
25
 
26
26
  module PhusionPassenger
27
27
  module Utils
@@ -22,7 +22,7 @@
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/platform_info/operating_system'
25
+ PhusionPassenger.require_passenger_lib 'platform_info/operating_system'
26
26
 
27
27
  module PhusionPassenger
28
28
  module Utils
@@ -54,7 +54,7 @@
54
54
  # PURPOSE.
55
55
 
56
56
  require 'stringio'
57
- require 'phusion_passenger/utils/tmpio'
57
+ PhusionPassenger.require_passenger_lib 'utils/tmpio'
58
58
 
59
59
  module PhusionPassenger
60
60
  module Utils
@@ -0,0 +1,217 @@
1
+ # encoding: utf-8
2
+ # Phusion Passenger - https://www.phusionpassenger.com/
3
+ # Copyright (c) 2013 Phusion
4
+ #
5
+ # "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in
15
+ # all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ # THE SOFTWARE.
24
+
25
+ module PhusionPassenger
26
+ module Utils
27
+
28
+ class TerminalChoiceMenu
29
+ class Choice
30
+ attr_reader :name
31
+ attr_accessor :checked
32
+
33
+ alias checked? checked
34
+
35
+ def self.create(choice)
36
+ if choice.is_a?(Choice)
37
+ return choice
38
+ else
39
+ return Choice.new(choice)
40
+ end
41
+ end
42
+
43
+ def initialize(name, checked = false)
44
+ @name = name
45
+ @checked = checked
46
+ end
47
+
48
+ def toggle!
49
+ @checked = !@checked
50
+ end
51
+ end
52
+
53
+ def initialize(choices)
54
+ @choices = choices.map { |choice| Choice.create(choice) }
55
+ @pointer = 0
56
+ @index = index_choices
57
+ initialize_terminal_control
58
+ end
59
+
60
+ def display_choices
61
+ display(render_to_string)
62
+ end
63
+
64
+ def query
65
+ if STDIN.tty?
66
+ done = false
67
+ begin
68
+ raw_no_echo_mode
69
+ hide_cursor
70
+ while !done
71
+ display_choices
72
+ done = process_input
73
+ clear_screen if !done
74
+ end
75
+ ensure
76
+ restore_mode
77
+ show_cursor
78
+ puts
79
+ end
80
+ else
81
+ display_choices
82
+ puts
83
+ end
84
+ end
85
+
86
+ def [](name)
87
+ return @index[name]
88
+ end
89
+
90
+ def selected_choices
91
+ @choices.find_all{ |c| c.checked? }.map{ |c| c.name }
92
+ end
93
+
94
+ private
95
+ JRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
96
+
97
+ def index_choices
98
+ index = {}
99
+ @choices.each do |choice|
100
+ index[choice.name] = choice
101
+ end
102
+ return index
103
+ end
104
+
105
+ def process_input
106
+ case STDIN.getc
107
+ when "\x1b"
108
+ process_cursor_move
109
+ return false
110
+ when " "
111
+ process_toggle
112
+ return false
113
+ when "\r"
114
+ return true
115
+ else
116
+ return false
117
+ end
118
+ end
119
+
120
+ def process_cursor_move
121
+ if STDIN.getc == "["
122
+ case STDIN.getc
123
+ when "A" # up
124
+ @pointer = [@pointer - 1, 0].max
125
+ when "B" # down
126
+ @pointer = [@pointer + 1, @choices.size - 1].min
127
+ end
128
+ end
129
+ end
130
+
131
+ def process_toggle
132
+ @choices[@pointer].toggle!
133
+ end
134
+
135
+ def render_to_string
136
+ str = ""
137
+ @choices.each_with_index do |choice, i|
138
+ pointer = render_pointer(i)
139
+ checkbox = render_checkbox(choice.checked)
140
+ str << " #{pointer} #{checkbox} #{choice.name}\r\n"
141
+ end
142
+ str.chomp!
143
+ return str
144
+ end
145
+
146
+ def render_pointer(index)
147
+ return @pointer == index ? "‣" : " "
148
+ end
149
+
150
+ def render_checkbox(checked)
151
+ return checked ? "⬢" : "⬡"
152
+ end
153
+
154
+ def display(str)
155
+ STDOUT.write(str)
156
+ STDOUT.flush
157
+ end
158
+
159
+ def clear_screen
160
+ number_of_lines = render_to_string.split("\n").size
161
+ display("\r")
162
+ (number_of_lines - 1).times do
163
+ display(move_up)
164
+ end
165
+ end
166
+
167
+ def hide_cursor
168
+ display("\x1b[?25l")
169
+ end
170
+
171
+ def show_cursor
172
+ display("\x1b[?25h")
173
+ end
174
+
175
+ def move_up
176
+ return "\x1b[0A"
177
+ end
178
+
179
+ if JRUBY
180
+ require 'java'
181
+ require 'readline'
182
+ java_import 'jline.console.ConsoleReader'
183
+
184
+ def initialize_terminal_control
185
+ input = STDIN.to_inputstream
186
+ output = STDOUT.to_outputstream
187
+ @console = ConsoleReader.new(input, output)
188
+ @console.set_history_enabled(false)
189
+ @console.set_bell_enabled(true)
190
+ @console.set_pagination_enabled(false)
191
+ end
192
+
193
+ def raw_no_echo_mode
194
+ @terminal_state = @console.getEchoCharacter
195
+ @console.setEchoCharacter(0)
196
+ end
197
+
198
+ def restore_mode
199
+ @console.setEchoCharacter(@terminal_state)
200
+ end
201
+ else
202
+ def initialize_terminal_control
203
+ end
204
+
205
+ def raw_no_echo_mode
206
+ @terminal_state = `stty -g`
207
+ system("stty raw -echo -icanon isig")
208
+ end
209
+
210
+ def restore_mode
211
+ system("stty #{@terminal_state}")
212
+ end
213
+ end
214
+ end
215
+
216
+ end # module Utils
217
+ end # module PhusionPassenger