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
@@ -122,17 +122,8 @@ private:
122
122
  return false;
123
123
  }
124
124
 
125
- VariantMap map;
126
- vector<string>::const_iterator it = args.begin(), end = args.end();
127
- it++;
128
- while (it != end) {
129
- const string &key = *it;
130
- it++;
131
- const string &value = *it;
132
- map.set(key, value);
133
- it++;
134
- }
135
- writeScalarMessage(commonContext.fd, pool->inspect(Pool::InspectOptions(map)));
125
+ VariantMap options = argsToOptions(args);
126
+ writeScalarMessage(commonContext.fd, pool->inspect(Pool::InspectOptions(options)));
136
127
  return true;
137
128
  }
138
129
 
@@ -155,6 +146,22 @@ private:
155
146
  writeScalarMessage(commonContext.fd, oxt::thread::all_backtraces());
156
147
  }
157
148
 
149
+ void processRestartAppGroup(CommonClientContext &commonContext, SpecificContext *specificContext,
150
+ const vector<string> &args)
151
+ {
152
+ TRACE_POINT();
153
+ commonContext.requireRights(Account::RESTART);
154
+ VariantMap options = argsToOptions(args, 2);
155
+ RestartMethod method = RM_DEFAULT;
156
+ if (options.get("method", false) == "blocking") {
157
+ method = RM_BLOCKING;
158
+ } else if (options.get("method", false) == "rolling") {
159
+ method = RM_ROLLING;
160
+ }
161
+ bool result = pool->restartGroupByName(args[1], method);
162
+ writeArrayMessage(commonContext.fd, result ? "true" : "false", NULL);
163
+ }
164
+
158
165
  void processRequests(CommonClientContext &commonContext, SpecificContext *specificContext,
159
166
  const vector<string> &args)
160
167
  {
@@ -191,6 +198,8 @@ public:
191
198
  processToXml(commonContext, specificContext, args);
192
199
  } else if (isCommand(args, "backtraces", 0)) {
193
200
  processBacktraces(commonContext, specificContext, args);
201
+ } else if (isCommand(args, "restart_app_group", 1, 99)) {
202
+ processRestartAppGroup(commonContext, specificContext, args);
194
203
  } else if (isCommand(args, "requests", 0)) {
195
204
  processRequests(commonContext, specificContext, args);
196
205
  } else {
@@ -424,7 +433,8 @@ public:
424
433
  accountsDatabase = boost::make_shared<AccountsDatabase>();
425
434
  accountsDatabase->add("_passenger-status", options.adminToolStatusPassword, false,
426
435
  Account::INSPECT_BASIC_INFO | Account::INSPECT_SENSITIVE_INFO |
427
- Account::INSPECT_BACKTRACES | Account::INSPECT_REQUESTS);
436
+ Account::INSPECT_BACKTRACES | Account::INSPECT_REQUESTS |
437
+ Account::RESTART);
428
438
  accountsDatabase->add("_web_server", options.exitPassword, false, Account::EXIT);
429
439
  messageServer = boost::make_shared<MessageServer>(
430
440
  parseUnixSocketAddress(options.adminSocketAddress), accountsDatabase);
@@ -579,6 +589,7 @@ public:
579
589
  */
580
590
  P_DEBUG("Received command to exit gracefully. "
581
591
  "Waiting until 5 seconds after all clients have disconnected...");
592
+ requestHandler->resetInactivityTime();
582
593
  while (requestHandler->inactivityTime() < 5000) {
583
594
  syscalls::usleep(250000);
584
595
  }
@@ -639,6 +639,10 @@ private:
639
639
  // GDB helper function, implemented in .cpp file to prevent inlining.
640
640
  Client *getClientPointer(const ClientPtr &client);
641
641
 
642
+ void doResetInactivityTime() {
643
+ inactivityTimer.reset();
644
+ }
645
+
642
646
  void getInactivityTime(unsigned long long *result) const {
643
647
  *result = inactivityTimer.elapsed();
644
648
  }
@@ -1297,7 +1301,8 @@ private:
1297
1301
  if (accept4Available) {
1298
1302
  FileDescriptor fd(callAccept4(requestSocket,
1299
1303
  (struct sockaddr *) &u, &addrlen, O_NONBLOCK));
1300
- if (fd == -1 && errno == ENOSYS) {
1304
+ // FreeBSD returns EINVAL if accept4() is called with invalid flags.
1305
+ if (fd == -1 && (errno == ENOSYS || errno == EINVAL)) {
1301
1306
  accept4Available = false;
1302
1307
  return acceptNonBlockingSocket(sock);
1303
1308
  } else {
@@ -2467,6 +2472,10 @@ public:
2467
2472
  }
2468
2473
  }
2469
2474
 
2475
+ void resetInactivityTime() {
2476
+ libev->run(boost::bind(&RequestHandler::doResetInactivityTime, this));
2477
+ }
2478
+
2470
2479
  unsigned long long inactivityTime() const {
2471
2480
  unsigned long long result;
2472
2481
  libev->run(boost::bind(&RequestHandler::getInactivityTime, this, &result));
@@ -920,6 +920,7 @@ private:
920
920
  union {
921
921
  struct {
922
922
  char stringStorage[sizeof(string)];
923
+ string *stringPointer;
923
924
  struct {
924
925
  regex_t regexp;
925
926
  int options;
@@ -945,7 +946,8 @@ private:
945
946
  } else {
946
947
  source = STRING_LITERAL;
947
948
  }
948
- new (u.stringOrRegexpValue.stringStorage) string(value.data(), value.size());
949
+ u.stringOrRegexpValue.stringPointer = new (u.stringOrRegexpValue.stringStorage)
950
+ string(value.data(), value.size());
949
951
  if (regexp) {
950
952
  int options = REG_EXTENDED;
951
953
  u.stringOrRegexpValue.regexp.options = 0;
@@ -955,7 +957,7 @@ private:
955
957
  Tokenizer::REGEXP_OPTION_CASE_INSENSITIVE;
956
958
  }
957
959
  regcomp(&u.stringOrRegexpValue.regexp.regexp,
958
- value.toString().c_str(),
960
+ u.stringOrRegexpValue.stringPointer->c_str(),
959
961
  options);
960
962
  }
961
963
  }
@@ -1066,7 +1068,7 @@ private:
1066
1068
 
1067
1069
  private:
1068
1070
  const string &storedString() const {
1069
- return *((string *) u.stringOrRegexpValue.stringStorage);
1071
+ return *u.stringOrRegexpValue.stringPointer;
1070
1072
  }
1071
1073
 
1072
1074
  regex_t &storedRegexp() const {
@@ -1087,7 +1089,8 @@ private:
1087
1089
  source = other.source;
1088
1090
  switch (source) {
1089
1091
  case REGEXP_LITERAL:
1090
- new (u.stringOrRegexpValue.stringStorage) string(other.storedString());
1092
+ u.stringOrRegexpValue.stringPointer = new (u.stringOrRegexpValue.stringStorage)
1093
+ string(other.storedString());
1091
1094
  options = REG_EXTENDED;
1092
1095
  if (other.u.stringOrRegexpValue.regexp.options & Tokenizer::REGEXP_OPTION_CASE_INSENSITIVE) {
1093
1096
  options |= REG_ICASE;
@@ -1098,7 +1101,8 @@ private:
1098
1101
  u.stringOrRegexpValue.regexp.options = other.u.stringOrRegexpValue.regexp.options;
1099
1102
  break;
1100
1103
  case STRING_LITERAL:
1101
- new (u.stringOrRegexpValue.stringStorage) string(other.storedString());
1104
+ u.stringOrRegexpValue.stringPointer = new (u.stringOrRegexpValue.stringStorage)
1105
+ string(other.storedString());
1102
1106
  break;
1103
1107
  case INTEGER_LITERAL:
1104
1108
  u.intValue = other.u.intValue;
@@ -113,7 +113,7 @@ initialize(int argc, char *argv[]) {
113
113
  parseArguments(argc, argv);
114
114
 
115
115
  if (logFile != NULL) {
116
- fd = open(logFile, O_WRONLY | O_APPEND | O_CREAT);
116
+ fd = open(logFile, O_WRONLY | O_APPEND | O_CREAT, 0644);
117
117
  if (fd == -1) {
118
118
  e = errno;
119
119
  fprintf(stderr, ERROR_PREFIX
@@ -148,7 +148,10 @@ initialize(int argc, char *argv[]) {
148
148
 
149
149
  static void
150
150
  exitHandler(int signo) {
151
- write(terminationPipe[1], "x", 1);
151
+ int ret = write(terminationPipe[1], "x", 1);
152
+ // We can't do anything about failures, so ignore
153
+ // compiler warnings about not using the result.
154
+ (void) ret;
152
155
  }
153
156
 
154
157
  static void
@@ -180,7 +183,13 @@ maybeDaemonize() {
180
183
  pid = fork();
181
184
  if (pid == 0) {
182
185
  setsid();
183
- chdir("/");
186
+ if (chdir("/") == -1) {
187
+ e = errno;
188
+ fprintf(stderr, ERROR_PREFIX
189
+ ": cannot change working directory to /: %s (errno %d)\n",
190
+ strerror(e), e);
191
+ _exit(1);
192
+ }
184
193
  redirectStdinToNull();
185
194
  } else if (pid == -1) {
186
195
  e = errno;
@@ -172,7 +172,10 @@ setOomScore(const StaticString &score) {
172
172
 
173
173
  f = openOomAdjFile("w", type);
174
174
  if (f != NULL) {
175
- fwrite(score.data(), 1, score.size(), f);
175
+ size_t ret = fwrite(score.data(), 1, score.size(), f);
176
+ // We can't do anything about failures, so ignore compiler
177
+ // warnings about not doing anything with the result.
178
+ (void) ret;
176
179
  fclose(f);
177
180
  }
178
181
  }
@@ -467,7 +470,10 @@ initializeBareEssentials(int argc, char *argv[]) {
467
470
  agentsOptions = initializeAgent(argc, argv, "PassengerWatchdog");
468
471
 
469
472
  if (agentsOptions.get("test_binary", false) == "1") {
470
- write(oldStdout, "PASS\n", 5);
473
+ int ret;
474
+ do {
475
+ ret = write(oldStdout, "PASS\n", 5);
476
+ } while (ret == -1 && errno == EAGAIN);
471
477
  exit(0);
472
478
  }
473
479
  close(oldStdout);
@@ -149,6 +149,16 @@
149
149
  NULL
150
150
  },
151
151
 
152
+ {
153
+
154
+ ngx_string("passenger_document_root"),
155
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_HTTP_LIF_CONF | NGX_CONF_TAKE1,
156
+ ngx_conf_set_str_slot,
157
+ NGX_HTTP_LOC_CONF_OFFSET,
158
+ offsetof(passenger_loc_conf_t, document_root),
159
+ NULL
160
+ },
161
+
152
162
  {
153
163
 
154
164
  ngx_string("passenger_user"),
@@ -79,6 +79,8 @@
79
79
 
80
80
  ngx_str_t app_type;
81
81
 
82
+ ngx_str_t document_root;
83
+
82
84
  ngx_str_t environment;
83
85
 
84
86
  ngx_str_t group;
@@ -87,6 +87,16 @@ file_exists(const u_char *filename, unsigned int throttle_rate) {
87
87
  return get_file_type(filename, throttle_rate) == FT_FILE;
88
88
  }
89
89
 
90
+ static int
91
+ mapped_filename_equals(const u_char *filename, size_t filename_len, ngx_str_t *str)
92
+ {
93
+ return (str->len == filename_len &&
94
+ memcmp(str->data, filename, filename_len) == 0) ||
95
+ (str->len == filename_len - 1 &&
96
+ filename[filename_len - 1] == '/' &&
97
+ memcmp(str->data, filename, filename_len - 1) == 0);
98
+ }
99
+
90
100
  /**
91
101
  * Maps the URI for the given request to a page cache file, if possible.
92
102
  *
@@ -115,16 +125,12 @@ map_uri_to_page_cache_file(ngx_http_request_t *r, ngx_str_t *public_dir,
115
125
 
116
126
  /* From this point on we know that filename is not an empty string. */
117
127
 
118
- /* Check whether filename is equal to public_dir. filename may also be equal to
119
- * public_dir + "/" so check for that as well.
128
+
129
+ /* Check whether `filename` is equal to public_dir.
130
+ * `filename` may also be equal to public_dir + "/" so check for that as well.
120
131
  */
121
- if ((public_dir->len == filename_len && memcmp(public_dir->data, filename,
122
- filename_len) == 0) ||
123
- (public_dir->len == filename_len - 1 &&
124
- filename[filename_len - 1] == '/' &&
125
- memcmp(public_dir->data, filename, filename_len - 1) == 0)
126
- ) {
127
- /* If the URI maps to the 'public' directory (i.e. the request is the
132
+ if (mapped_filename_equals(filename, filename_len, public_dir)) {
133
+ /* If the URI maps to the 'public' or the alias directory (i.e. the request is the
128
134
  * base URI) then index.html is the page cache file.
129
135
  */
130
136
 
@@ -1216,7 +1222,7 @@ passenger_content_handler(ngx_http_request_t *r)
1216
1222
  u_char *path_last, *end;
1217
1223
  u_char root_path_str[NGX_MAX_PATH + 1];
1218
1224
  ngx_str_t root_path;
1219
- size_t root, len;
1225
+ size_t root_len, len;
1220
1226
  u_char page_cache_file_str[NGX_MAX_PATH + 1];
1221
1227
  ngx_str_t page_cache_file;
1222
1228
  passenger_context_t *context;
@@ -1243,7 +1249,7 @@ passenger_content_handler(ngx_http_request_t *r)
1243
1249
  /* Let the next content handler take care of this request if this URL
1244
1250
  * maps to an existing file.
1245
1251
  */
1246
- path_last = ngx_http_map_uri_to_path(r, &path, &root, 0);
1252
+ path_last = ngx_http_map_uri_to_path(r, &path, &root_len, 0);
1247
1253
  if (path_last != NULL && file_exists(path.data, 0)) {
1248
1254
  return NGX_DECLINED;
1249
1255
  }
@@ -1251,10 +1257,10 @@ passenger_content_handler(ngx_http_request_t *r)
1251
1257
  /* Create a string containing the root path. This path already
1252
1258
  * contains a trailing slash.
1253
1259
  */
1254
- end = ngx_copy(root_path_str, path.data, root);
1260
+ end = ngx_copy(root_path_str, path.data, root_len);
1255
1261
  *end = '\0';
1256
1262
  root_path.data = root_path_str;
1257
- root_path.len = root;
1263
+ root_path.len = root_len;
1258
1264
 
1259
1265
 
1260
1266
  context = ngx_pcalloc(r->pool, sizeof(passenger_context_t));
@@ -1266,13 +1272,20 @@ passenger_content_handler(ngx_http_request_t *r)
1266
1272
 
1267
1273
  /* Find the base URI for this web application, if any. */
1268
1274
  if (find_base_uri(r, slcf, &base_uri)) {
1269
- /* Store the found base URI into context->public_dir. We infer that the 'public'
1270
- * directory of the web application is document root + base URI.
1275
+ /* Store the found base URI into context->public_dir. We infer that
1276
+ * the 'public' directory of the web app equals document root + base URI.
1271
1277
  */
1272
- len = root_path.len + base_uri.len + 1;
1273
- context->public_dir.data = ngx_palloc(r->pool, sizeof(u_char) * len);
1274
- end = ngx_copy(context->public_dir.data, root_path.data, root_path.len);
1275
- end = ngx_copy(end, base_uri.data, base_uri.len);
1278
+ if (slcf->document_root.data != NULL) {
1279
+ len = slcf->document_root.len + 1;
1280
+ context->public_dir.data = ngx_palloc(r->pool, sizeof(u_char) * len);
1281
+ end = ngx_copy(context->public_dir.data, slcf->document_root.data,
1282
+ slcf->document_root.len);
1283
+ } else {
1284
+ len = root_path.len + base_uri.len + 1;
1285
+ context->public_dir.data = ngx_palloc(r->pool, sizeof(u_char) * len);
1286
+ end = ngx_copy(context->public_dir.data, root_path.data, root_path.len);
1287
+ end = ngx_copy(end, base_uri.data, base_uri.len);
1288
+ }
1276
1289
  *end = '\0';
1277
1290
  context->public_dir.len = len - 1;
1278
1291
  context->base_uri = base_uri;
@@ -88,6 +88,11 @@
88
88
 
89
89
 
90
90
 
91
+ conf->document_root.data = NULL;
92
+ conf->document_root.len = 0;
93
+
94
+
95
+
91
96
  conf->user.data = NULL;
92
97
  conf->user.len = 0;
93
98
 
@@ -100,6 +100,12 @@
100
100
 
101
101
 
102
102
 
103
+ ngx_conf_merge_str_value(conf->document_root,
104
+ prev->document_root,
105
+ NULL);
106
+
107
+
108
+
103
109
  ngx_conf_merge_str_value(conf->user,
104
110
  prev->user,
105
111
  NULL);
@@ -1,13 +1,19 @@
1
- PATH="$ngx_addon_dir/../../bin:$PATH"
2
- export PATH
3
-
1
+ # passenger-config is run with the 'ruby' command in $PATH, even when natively packaged,
2
+ # so we check whether 'ruby' is correctly in $PATH.
4
3
  if ! ruby -v >/dev/null 2>/dev/null; then
5
4
  echo '*** ERROR: Cannot find the "ruby" command in $PATH. Please fix your $PATH. You can learn more about $PATH at: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_the_path_environment_variable'
6
5
  echo '*** Do you think that you set $PATH correctly, and you happen to be using sudo or rvmsudo? Read this: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#env_vars_and_sudo'
7
6
  exit 1
8
7
  fi
9
8
 
10
- if test "x$PASSENGER_LIBS" = "x" && ! passenger-config --compiled; then
9
+ ## Magic comment: begin bootstrap ##
10
+ # Ensure that this script finds the passenger-config that belongs to this Phusion Passenger installation.
11
+ PATH="$ngx_addon_dir/../../bin:$PATH"
12
+ export PATH
13
+
14
+ PASSENGER_CONFIG=${PASSENGER_CONFIG:-passenger-config}
15
+
16
+ if test "x$PASSENGER_LIBS" = "x" && ! $PASSENGER_CONFIG --compiled; then
11
17
  echo "*** The Phusion Passenger support files are not yet compiled. Compiling them for you... ***"
12
18
  echo "*** Running 'rake nginx CACHING=false' in $ngx_addon_dir... ***"
13
19
  old_dir=`pwd`
@@ -26,12 +32,13 @@ if test "x$PASSENGER_LIBS" = "x" && ! passenger-config --compiled; then
26
32
  cd "$old_dir"
27
33
  echo "*** Phusion Passenger support files have been successfully compiled. ***"
28
34
  fi
35
+ ## Magic comment: end bootstrap ##
29
36
 
30
37
  if test "x$PASSENGER_INCLUDEDIR" = "x"; then
31
- PASSENGER_INCLUDEDIR=`passenger-config --includedir`
38
+ PASSENGER_INCLUDEDIR=`$PASSENGER_CONFIG --includedir`
32
39
  fi
33
40
  if test "x$PASSENGER_LIBS" = "x"; then
34
- PASSENGER_LIBS=`passenger-config --nginx-libs`
41
+ PASSENGER_LIBS=`$PASSENGER_CONFIG --nginx-libs`
35
42
  fi
36
43
 
37
44
  ngx_addon_name=ngx_http_passenger_module
@@ -27,9 +27,11 @@
27
27
  /* Ruby 1.9 */
28
28
  #include "ruby/intern.h"
29
29
  #include "ruby/io.h"
30
+ #include "ruby/version.h"
30
31
  #else
31
32
  #include "rubysig.h"
32
33
  #include "rubyio.h"
34
+ #include "version.h"
33
35
  #endif
34
36
  #include <sys/types.h>
35
37
  #include <sys/stat.h>
@@ -861,8 +863,65 @@ void
861
863
  Init_passenger_native_support() {
862
864
  struct sockaddr_un addr;
863
865
 
864
- /* */
865
- mPassenger = rb_define_module("PhusionPassenger"); // Do not remove the above comment. We want the Passenger module's rdoc to be empty.
866
+ /* Only defined on Ruby >= 1.9 */
867
+ #ifdef RUBY_API_VERSION_CODE
868
+ if (ruby_api_version[0] != RUBY_API_VERSION_MAJOR
869
+ || ruby_api_version[1] != RUBY_API_VERSION_MINOR
870
+ || ruby_api_version[2] != RUBY_API_VERSION_TEENY)
871
+ {
872
+ fprintf(stderr, " --> passenger_native_support was compiled for Ruby API version %d.%d.%d, "
873
+ "but you're currently running a Ruby interpreter with API version %d.%d.%d.\n",
874
+ RUBY_API_VERSION_MAJOR,
875
+ RUBY_API_VERSION_MINOR,
876
+ RUBY_API_VERSION_TEENY,
877
+ ruby_api_version[0],
878
+ ruby_api_version[1],
879
+ ruby_api_version[2]);
880
+ fprintf(stderr, " Refusing to load existing passenger_native_support.\n");
881
+ return;
882
+ }
883
+ /* Because native extensions may be linked to libruby, loading
884
+ * a Ruby 1.9 native extension may not fail on Ruby 1.8 (even though
885
+ * the extension will crash later on). We detect such a case here and
886
+ * abort early.
887
+ */
888
+ if (strlen(ruby_version) >= sizeof("1.8.7") - 1
889
+ && ruby_version[0] == '1'
890
+ && ruby_version[1] == '.'
891
+ && ruby_version[2] == '8')
892
+ {
893
+ fprintf(stderr, " --> passenger_native_support was compiled for Ruby %d.%d, "
894
+ "but you're currently running Ruby %s\n",
895
+ RUBY_API_VERSION_MAJOR,
896
+ RUBY_API_VERSION_MINOR,
897
+ ruby_version);
898
+ fprintf(stderr, " Refusing to load existing passenger_native_support.\n");
899
+ return;
900
+ }
901
+ #else
902
+ if (strlen(ruby_version) < sizeof("1.8.7") - 1
903
+ || ruby_version[0] != '1'
904
+ || ruby_version[1] != '.'
905
+ || ruby_version[2] != '8')
906
+ {
907
+ /* We may not have included Ruby 1.8's version.h because of compiler
908
+ * header file search paths, so we can't rely on RUBY_VERSION being
909
+ * defined.
910
+ */
911
+ #ifdef RUBY_VERSION
912
+ #define ESTIMATED_RUBY_VERSION RUBY_VERSION
913
+ #else
914
+ #define ESTIMATED_RUBY_VERSION "1.8"
915
+ #endif
916
+ fprintf(stderr, " --> passenger_native_support was compiled for Ruby %s, "
917
+ "but you're currently running Ruby %s\n",
918
+ ESTIMATED_RUBY_VERSION, ruby_version);
919
+ fprintf(stderr, " Refusing to load existing passenger_native_support.\n");
920
+ return;
921
+ }
922
+ #endif
923
+
924
+ mPassenger = rb_define_module("PhusionPassenger");
866
925
 
867
926
  /*
868
927
  * Utility functions for accessing system functionality.