passenger 2.0.6 → 2.1.2

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 (497) hide show
  1. data/DEVELOPERS.TXT +10 -4
  2. data/LICENSE +1 -1
  3. data/NEWS +0 -0
  4. data/Rakefile +183 -117
  5. data/benchmark/dispatcher.rb +5 -9
  6. data/bin/passenger-install-apache2-module +52 -18
  7. data/bin/passenger-memory-stats +67 -13
  8. data/bin/passenger-spawn-server +8 -4
  9. data/bin/passenger-status +21 -46
  10. data/bin/passenger-stress-test +5 -5
  11. data/debian/postinst +1 -1
  12. data/doc/ApplicationPool algorithm.txt +180 -128
  13. data/doc/Architectural overview.html +1 -778
  14. data/doc/Security of user switching support.html +1 -643
  15. data/doc/Users guide Apache.html +3127 -0
  16. data/doc/Users guide Nginx.html +1458 -0
  17. data/doc/Users guide.html +1404 -467
  18. data/doc/Users guide.txt +843 -105
  19. data/doc/cxxapi/ApplicationPoolServer_8h-source.html +751 -641
  20. data/doc/cxxapi/ApplicationPool_8h-source.html +168 -171
  21. data/doc/cxxapi/Application_8h-source.html +494 -394
  22. data/doc/cxxapi/Bucket_8h-source.html +21 -15
  23. data/doc/cxxapi/CachedFileStat_8h-source.html +191 -0
  24. data/doc/cxxapi/Configuration_8h-source.html +311 -149
  25. data/doc/cxxapi/DirectoryMapper_8h-source.html +309 -0
  26. data/doc/cxxapi/DummySpawnManager_8h-source.html +3 -4
  27. data/doc/cxxapi/Exceptions_8h-source.html +182 -165
  28. data/doc/cxxapi/FileChecker_8h-source.html +130 -0
  29. data/doc/cxxapi/Hooks_8h-source.html +2 -3
  30. data/doc/cxxapi/Logging_8h-source.html +92 -89
  31. data/doc/cxxapi/MessageChannel_8h-source.html +585 -477
  32. data/doc/cxxapi/PoolOptions_8h-source.html +305 -0
  33. data/doc/cxxapi/SpawnManager_8h-source.html +515 -540
  34. data/doc/cxxapi/StandardApplicationPool_8h-source.html +779 -679
  35. data/doc/cxxapi/SystemTime_8h-source.html +104 -0
  36. data/doc/cxxapi/Utils_8h-source.html +331 -227
  37. data/doc/cxxapi/annotated.html +6 -7
  38. data/doc/cxxapi/classClient-members.html +1 -2
  39. data/doc/cxxapi/classClient.html +1 -2
  40. data/doc/cxxapi/classHooks-members.html +5 -2
  41. data/doc/cxxapi/classHooks.html +112 -2
  42. data/doc/cxxapi/classPassenger_1_1Application-members.html +2 -3
  43. data/doc/cxxapi/classPassenger_1_1Application.html +8 -9
  44. data/doc/cxxapi/classPassenger_1_1ApplicationPool-members.html +4 -4
  45. data/doc/cxxapi/classPassenger_1_1ApplicationPool.html +42 -81
  46. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer-members.html +1 -2
  47. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer.html +3 -4
  48. data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.png +0 -0
  49. data/doc/cxxapi/classPassenger_1_1Application_1_1Session-members.html +3 -2
  50. data/doc/cxxapi/classPassenger_1_1Application_1_1Session.html +74 -3
  51. data/doc/cxxapi/classPassenger_1_1BusyException-members.html +1 -2
  52. data/doc/cxxapi/classPassenger_1_1BusyException.html +2 -3
  53. data/doc/cxxapi/classPassenger_1_1ConfigurationException-members.html +1 -2
  54. data/doc/cxxapi/classPassenger_1_1ConfigurationException.html +2 -3
  55. data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +38 -0
  56. data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +256 -0
  57. data/doc/cxxapi/classPassenger_1_1DummySpawnManager-members.html +1 -2
  58. data/doc/cxxapi/classPassenger_1_1DummySpawnManager.html +2 -3
  59. data/doc/cxxapi/{classPassenger_1_1Thread-members.html → classPassenger_1_1FileChecker-members.html} +4 -5
  60. data/doc/cxxapi/classPassenger_1_1FileChecker.html +121 -0
  61. data/doc/cxxapi/classPassenger_1_1FileNotFoundException-members.html +1 -2
  62. data/doc/cxxapi/classPassenger_1_1FileNotFoundException.html +2 -3
  63. data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.png +0 -0
  64. data/doc/cxxapi/classPassenger_1_1FileSystemException-members.html +2 -3
  65. data/doc/cxxapi/classPassenger_1_1FileSystemException.html +2 -3
  66. data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.png +0 -0
  67. data/doc/cxxapi/classPassenger_1_1IOException-members.html +1 -2
  68. data/doc/cxxapi/classPassenger_1_1IOException.html +2 -3
  69. data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.png +0 -0
  70. data/doc/cxxapi/classPassenger_1_1MessageChannel-members.html +5 -2
  71. data/doc/cxxapi/classPassenger_1_1MessageChannel.html +155 -5
  72. data/doc/cxxapi/{classboost_1_1this__thread_1_1enable__syscall__interruption-members.html → classPassenger_1_1RuntimeException-members.html} +2 -3
  73. data/doc/cxxapi/{classboost_1_1this__thread_1_1enable__syscall__interruption.html → classPassenger_1_1RuntimeException.html} +10 -8
  74. data/doc/cxxapi/classPassenger_1_1SpawnException-members.html +1 -2
  75. data/doc/cxxapi/classPassenger_1_1SpawnException.html +2 -3
  76. data/doc/cxxapi/classPassenger_1_1SpawnManager-members.html +2 -3
  77. data/doc/cxxapi/classPassenger_1_1SpawnManager.html +15 -56
  78. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool-members.html +5 -4
  79. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool.html +20 -81
  80. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.png +0 -0
  81. data/doc/cxxapi/classPassenger_1_1SystemException-members.html +2 -3
  82. data/doc/cxxapi/classPassenger_1_1SystemException.html +9 -10
  83. data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.png +0 -0
  84. data/doc/cxxapi/{classboost_1_1this__thread_1_1disable__syscall__interruption-members.html → classPassenger_1_1SystemTime-members.html} +5 -3
  85. data/doc/cxxapi/classPassenger_1_1SystemTime.html +86 -0
  86. data/doc/cxxapi/classPassenger_1_1TempFile-members.html +2 -3
  87. data/doc/cxxapi/classPassenger_1_1TempFile.html +17 -9
  88. data/doc/cxxapi/definitions_8h-source.html +1 -2
  89. data/doc/cxxapi/files.html +6 -3
  90. data/doc/cxxapi/functions.html +98 -35
  91. data/doc/cxxapi/functions_func.html +60 -32
  92. data/doc/cxxapi/functions_type.html +1 -2
  93. data/doc/cxxapi/functions_vars.html +27 -2
  94. data/doc/cxxapi/graph_legend.html +1 -2
  95. data/doc/cxxapi/graph_legend.png +0 -0
  96. data/doc/cxxapi/group__Configuration.html +3 -4
  97. data/doc/cxxapi/group__Configuration.png +0 -0
  98. data/doc/cxxapi/group__Core.html +3 -4
  99. data/doc/cxxapi/group__Core.png +0 -0
  100. data/doc/cxxapi/group__Exceptions.html +4 -2
  101. data/doc/cxxapi/group__Hooks.html +1 -6
  102. data/doc/cxxapi/group__Hooks.png +0 -0
  103. data/doc/cxxapi/group__Support.html +259 -36
  104. data/doc/cxxapi/hierarchy.html +6 -7
  105. data/doc/cxxapi/inherit__graph__0.map +1 -1
  106. data/doc/cxxapi/inherit__graph__0.md5 +1 -1
  107. data/doc/cxxapi/inherit__graph__0.png +0 -0
  108. data/doc/cxxapi/inherit__graph__1.map +1 -1
  109. data/doc/cxxapi/inherit__graph__1.md5 +1 -1
  110. data/doc/cxxapi/inherit__graph__1.png +0 -0
  111. data/doc/cxxapi/inherit__graph__10.map +1 -1
  112. data/doc/cxxapi/inherit__graph__10.md5 +1 -1
  113. data/doc/cxxapi/inherit__graph__10.png +0 -0
  114. data/doc/cxxapi/inherit__graph__11.map +1 -1
  115. data/doc/cxxapi/inherit__graph__11.md5 +1 -1
  116. data/doc/cxxapi/inherit__graph__11.png +0 -0
  117. data/doc/cxxapi/inherit__graph__12.map +2 -1
  118. data/doc/cxxapi/inherit__graph__12.md5 +1 -1
  119. data/doc/cxxapi/inherit__graph__12.png +0 -0
  120. data/doc/cxxapi/inherit__graph__13.map +1 -1
  121. data/doc/cxxapi/inherit__graph__13.md5 +1 -1
  122. data/doc/cxxapi/inherit__graph__13.png +0 -0
  123. data/doc/cxxapi/inherit__graph__14.map +1 -2
  124. data/doc/cxxapi/inherit__graph__14.md5 +1 -1
  125. data/doc/cxxapi/inherit__graph__14.png +0 -0
  126. data/doc/cxxapi/inherit__graph__15.map +1 -1
  127. data/doc/cxxapi/inherit__graph__15.md5 +1 -1
  128. data/doc/cxxapi/inherit__graph__15.png +0 -0
  129. data/doc/cxxapi/inherit__graph__16.map +1 -1
  130. data/doc/cxxapi/inherit__graph__16.md5 +1 -1
  131. data/doc/cxxapi/inherit__graph__16.png +0 -0
  132. data/doc/cxxapi/inherit__graph__17.png +0 -0
  133. data/doc/cxxapi/inherit__graph__18.png +0 -0
  134. data/doc/cxxapi/inherit__graph__19.png +0 -0
  135. data/doc/cxxapi/inherit__graph__2.map +1 -1
  136. data/doc/cxxapi/inherit__graph__2.md5 +1 -1
  137. data/doc/cxxapi/inherit__graph__2.png +0 -0
  138. data/doc/cxxapi/inherit__graph__20.map +1 -1
  139. data/doc/cxxapi/inherit__graph__20.md5 +1 -1
  140. data/doc/cxxapi/inherit__graph__20.png +0 -0
  141. data/doc/cxxapi/inherit__graph__21.map +1 -1
  142. data/doc/cxxapi/inherit__graph__21.md5 +1 -1
  143. data/doc/cxxapi/inherit__graph__21.png +0 -0
  144. data/doc/cxxapi/inherit__graph__3.map +1 -1
  145. data/doc/cxxapi/inherit__graph__3.md5 +1 -1
  146. data/doc/cxxapi/inherit__graph__3.png +0 -0
  147. data/doc/cxxapi/inherit__graph__4.map +1 -1
  148. data/doc/cxxapi/inherit__graph__4.md5 +1 -1
  149. data/doc/cxxapi/inherit__graph__4.png +0 -0
  150. data/doc/cxxapi/inherit__graph__5.map +2 -1
  151. data/doc/cxxapi/inherit__graph__5.md5 +1 -1
  152. data/doc/cxxapi/inherit__graph__5.png +0 -0
  153. data/doc/cxxapi/inherit__graph__6.map +1 -1
  154. data/doc/cxxapi/inherit__graph__6.md5 +1 -1
  155. data/doc/cxxapi/inherit__graph__6.png +0 -0
  156. data/doc/cxxapi/inherit__graph__7.map +1 -1
  157. data/doc/cxxapi/inherit__graph__7.md5 +1 -1
  158. data/doc/cxxapi/inherit__graph__7.png +0 -0
  159. data/doc/cxxapi/inherit__graph__8.map +1 -1
  160. data/doc/cxxapi/inherit__graph__8.md5 +1 -1
  161. data/doc/cxxapi/inherit__graph__8.png +0 -0
  162. data/doc/cxxapi/inherit__graph__9.map +1 -2
  163. data/doc/cxxapi/inherit__graph__9.md5 +1 -1
  164. data/doc/cxxapi/inherit__graph__9.png +0 -0
  165. data/doc/cxxapi/inherits.html +30 -31
  166. data/doc/cxxapi/main.html +1 -2
  167. data/doc/cxxapi/modules.html +1 -2
  168. data/doc/cxxapi/structPassenger_1_1AnythingToString-members.html +1 -2
  169. data/doc/cxxapi/structPassenger_1_1AnythingToString.html +2 -3
  170. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4-members.html +1 -2
  171. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4.html +2 -3
  172. data/doc/cxxapi/structPassenger_1_1PoolOptions-members.html +49 -0
  173. data/doc/cxxapi/structPassenger_1_1PoolOptions.html +404 -0
  174. data/doc/cxxapi/tree.html +18 -20
  175. data/doc/images/conservative_spawning.png +0 -0
  176. data/doc/images/conservative_spawning.svg +248 -0
  177. data/doc/images/smart-lv2.png +0 -0
  178. data/doc/images/smart-lv2.svg +320 -0
  179. data/doc/rdoc/classes/ConditionVariable.html +68 -34
  180. data/doc/rdoc/classes/Exception.html +16 -16
  181. data/doc/rdoc/classes/GC.html +9 -9
  182. data/doc/rdoc/classes/IO.html +36 -17
  183. data/doc/rdoc/classes/PhusionPassenger.html +183 -0
  184. data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +511 -0
  185. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer.html +285 -242
  186. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/ServerAlreadyStarted.html +3 -3
  187. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/ServerError.html +3 -3
  188. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/ServerNotStarted.html +3 -3
  189. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/UnknownMessage.html +3 -3
  190. data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +598 -0
  191. data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +140 -0
  192. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess.html +247 -0
  193. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess/Instance.html +138 -0
  194. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AppInitError.html +36 -19
  195. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/Application.html +81 -96
  196. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/ConsoleTextTemplate.html +18 -18
  197. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/FrameworkInitError.html +20 -18
  198. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/HTMLTemplate.html +18 -18
  199. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/InitializationError.html +9 -9
  200. data/doc/rdoc/classes/PhusionPassenger/InvalidPath.html +92 -0
  201. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/MessageChannel.html +93 -92
  202. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/NativeSupport.html +55 -25
  203. data/doc/rdoc/classes/PhusionPassenger/Rack.html +91 -0
  204. data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +185 -0
  205. data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +182 -0
  206. data/doc/rdoc/classes/PhusionPassenger/Railz.html +95 -0
  207. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +424 -0
  208. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner/Error.html +98 -0
  209. data/doc/rdoc/classes/PhusionPassenger/Railz/CGIFixed.html +200 -0
  210. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +444 -0
  211. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner/Error.html +98 -0
  212. data/doc/rdoc/classes/PhusionPassenger/Railz/RequestHandler.html +154 -0
  213. data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +408 -0
  214. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/UnknownError.html +13 -13
  215. data/doc/rdoc/classes/PhusionPassenger/Utils.html +687 -0
  216. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/VersionNotFound.html +8 -8
  217. data/doc/rdoc/classes/PhusionPassenger/WSGI.html +89 -0
  218. data/doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html +188 -0
  219. data/doc/rdoc/classes/PlatformInfo.html +663 -159
  220. data/doc/rdoc/classes/RakeExtensions.html +4 -4
  221. data/doc/rdoc/classes/Signal.html +134 -0
  222. data/doc/rdoc/created.rid +1 -1
  223. data/doc/rdoc/files/DEVELOPERS_TXT.html +15 -10
  224. data/doc/rdoc/files/README.html +5 -7
  225. data/doc/rdoc/files/ext/{passenger → phusion_passenger}/native_support_c.html +2 -2
  226. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/abstract_request_handler_rb.html +7 -9
  227. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +120 -0
  228. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/abstract_server_rb.html +7 -10
  229. data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +99 -0
  230. data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +92 -0
  231. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/application_rb.html +6 -8
  232. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/console_text_template_rb.html +5 -7
  233. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/constants_rb.html +4 -5
  234. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/dependencies_rb.html +6 -8
  235. data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +116 -0
  236. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/exceptions_rb.html +5 -7
  237. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/html_template_rb.html +5 -7
  238. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/message_channel_rb.html +5 -7
  239. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/platform_info_rb.html +6 -7
  240. data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +123 -0
  241. data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +117 -0
  242. data/doc/rdoc/files/lib/{passenger/utils_rb.html → phusion_passenger/railz/application_spawner_rb.html} +24 -17
  243. data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +126 -0
  244. data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +139 -0
  245. data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +118 -0
  246. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/simple_benchmarking_rb.html +5 -7
  247. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/spawn_manager_rb.html +40 -24
  248. data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +169 -0
  249. data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +120 -0
  250. data/doc/rdoc/files/lib/rake/extensions_rb.html +3 -4
  251. data/doc/rdoc/fr_class_index.html +37 -19
  252. data/doc/rdoc/fr_file_index.html +25 -14
  253. data/doc/rdoc/fr_method_index.html +145 -74
  254. data/ext/apache2/Application.h +145 -44
  255. data/ext/apache2/ApplicationPool.h +27 -29
  256. data/ext/apache2/ApplicationPoolServer.h +183 -72
  257. data/ext/apache2/ApplicationPoolServerExecutable.cpp +249 -42
  258. data/ext/apache2/Bucket.cpp +61 -9
  259. data/ext/apache2/Bucket.h +15 -8
  260. data/ext/apache2/CachedFileStat.cpp +114 -0
  261. data/ext/apache2/CachedFileStat.h +169 -0
  262. data/ext/apache2/Configuration.cpp +213 -22
  263. data/ext/apache2/Configuration.h +176 -13
  264. data/ext/apache2/DirectoryMapper.h +287 -0
  265. data/ext/apache2/Exceptions.h +30 -12
  266. data/ext/apache2/FileChecker.h +108 -0
  267. data/ext/apache2/Hooks.cpp +709 -493
  268. data/ext/apache2/LICENSE-CNRI.TXT +15 -0
  269. data/ext/apache2/Logging.h +26 -22
  270. data/ext/apache2/MessageChannel.h +124 -15
  271. data/ext/apache2/PoolOptions.h +283 -0
  272. data/ext/apache2/SpawnManager.h +75 -99
  273. data/ext/apache2/StandardApplicationPool.h +296 -195
  274. data/ext/apache2/SystemTime.cpp +28 -0
  275. data/ext/apache2/SystemTime.h +82 -0
  276. data/ext/apache2/Utils.cpp +172 -18
  277. data/ext/apache2/Utils.h +124 -19
  278. data/ext/boost/cstdint.hpp +4 -2
  279. data/ext/boost/current_function.hpp +67 -0
  280. data/ext/boost/detail/sp_counted_base.hpp +4 -4
  281. data/ext/boost/thread/exceptions.hpp +2 -1
  282. data/ext/boost/thread/pthread/thread.hpp +11 -3
  283. data/ext/boost/thread/pthread/thread_data.hpp +2 -1
  284. data/ext/oxt/backtrace.cpp +172 -0
  285. data/ext/oxt/backtrace.hpp +135 -0
  286. data/ext/oxt/detail/backtrace_disabled.hpp +39 -0
  287. data/ext/oxt/detail/backtrace_enabled.hpp +155 -0
  288. data/ext/oxt/detail/spin_lock_gcc_x86.hpp +82 -0
  289. data/ext/oxt/detail/spin_lock_portable.hpp +38 -0
  290. data/ext/oxt/detail/spin_lock_pthreads.hpp +97 -0
  291. data/ext/oxt/detail/tracable_exception_disabled.hpp +46 -0
  292. data/ext/oxt/detail/tracable_exception_enabled.hpp +48 -0
  293. data/ext/oxt/macros.hpp +58 -0
  294. data/ext/oxt/spin_lock.hpp +55 -0
  295. data/ext/{apache2/System.cpp → oxt/system_calls.cpp} +87 -52
  296. data/ext/oxt/system_calls.hpp +234 -0
  297. data/ext/oxt/thread.cpp +32 -0
  298. data/ext/oxt/thread.hpp +223 -0
  299. data/ext/oxt/tracable_exception.cpp +87 -0
  300. data/ext/oxt/tracable_exception.hpp +35 -0
  301. data/{lib/passenger/constants.rb → ext/phusion_passenger/extconf.rb} +14 -9
  302. data/ext/{passenger → phusion_passenger}/native_support.c +33 -6
  303. data/lib/{passenger → phusion_passenger}/abstract_request_handler.rb +209 -93
  304. data/lib/{passenger → phusion_passenger}/abstract_server.rb +23 -8
  305. data/lib/phusion_passenger/abstract_server_collection.rb +301 -0
  306. data/lib/phusion_passenger/admin_tools.rb +25 -0
  307. data/lib/phusion_passenger/admin_tools/control_process.rb +107 -0
  308. data/lib/{passenger → phusion_passenger}/application.rb +13 -16
  309. data/lib/{passenger → phusion_passenger}/console_text_template.rb +2 -2
  310. data/{ext/passenger/extconf.rb → lib/phusion_passenger/constants.rb} +5 -5
  311. data/lib/{passenger → phusion_passenger}/dependencies.rb +38 -32
  312. data/lib/phusion_passenger/events.rb +45 -0
  313. data/lib/{passenger → phusion_passenger}/exceptions.rb +12 -5
  314. data/lib/{passenger → phusion_passenger}/html_template.rb +2 -2
  315. data/lib/{passenger → phusion_passenger}/message_channel.rb +3 -2
  316. data/lib/phusion_passenger/platform_info.rb +500 -0
  317. data/lib/{passenger → phusion_passenger}/rack/application_spawner.rb +29 -22
  318. data/lib/{passenger → phusion_passenger}/rack/request_handler.rb +14 -9
  319. data/lib/{passenger → phusion_passenger}/railz/application_spawner.rb +94 -74
  320. data/lib/{passenger → phusion_passenger}/railz/cgi_fixed.rb +2 -2
  321. data/lib/{passenger → phusion_passenger}/railz/framework_spawner.rb +86 -98
  322. data/lib/{passenger → phusion_passenger}/railz/request_handler.rb +6 -6
  323. data/lib/{passenger → phusion_passenger}/simple_benchmarking.rb +0 -0
  324. data/lib/{passenger → phusion_passenger}/spawn_manager.rb +136 -128
  325. data/lib/{passenger → phusion_passenger}/templates/apache2_config_snippets.txt.erb +0 -0
  326. data/lib/{passenger → phusion_passenger}/templates/apache_must_be_compiled_with_compatible_mpm.txt.erb +0 -0
  327. data/lib/phusion_passenger/templates/app_exited_during_initialization.html.erb +38 -0
  328. data/lib/{passenger → phusion_passenger}/templates/app_init_error.html.erb +0 -0
  329. data/lib/{passenger → phusion_passenger}/templates/database_error.html.erb +0 -0
  330. data/lib/{passenger → phusion_passenger}/templates/deployment_example.txt.erb +1 -1
  331. data/lib/{passenger → phusion_passenger}/templates/error_layout.css +0 -0
  332. data/lib/{passenger → phusion_passenger}/templates/error_layout.html.erb +0 -0
  333. data/lib/{passenger → phusion_passenger}/templates/framework_init_error.html.erb +0 -0
  334. data/lib/{passenger → phusion_passenger}/templates/general_error.html.erb +0 -0
  335. data/lib/{passenger → phusion_passenger}/templates/invalid_app_root.html.erb +1 -1
  336. data/lib/{passenger → phusion_passenger}/templates/load_error.html.erb +0 -0
  337. data/lib/{passenger → phusion_passenger}/templates/no_write_permission_to_passenger_root.txt.erb +0 -0
  338. data/lib/{passenger → phusion_passenger}/templates/possible_solutions_for_compilation_and_installation_problems.txt.erb +0 -0
  339. data/lib/{passenger → phusion_passenger}/templates/run_installer_as_root.txt.erb +0 -0
  340. data/lib/{passenger → phusion_passenger}/templates/version_not_found.html.erb +0 -0
  341. data/lib/{passenger → phusion_passenger}/templates/welcome.txt.erb +0 -0
  342. data/lib/{passenger → phusion_passenger}/utils.rb +210 -44
  343. data/lib/{passenger → phusion_passenger}/wsgi/application_spawner.rb +18 -15
  344. data/lib/{passenger → phusion_passenger}/wsgi/request_handler.py +7 -1
  345. data/man/passenger-memory-stats.8 +1 -1
  346. data/misc/render_error_pages.rb +1 -1
  347. data/test/ApplicationPoolServerTest.cpp +0 -28
  348. data/test/ApplicationPoolServer_ApplicationPoolTest.cpp +4 -0
  349. data/test/ApplicationPoolTest.cpp +307 -69
  350. data/test/CachedFileStatTest.cpp +262 -0
  351. data/test/FileCheckerTest.cpp +79 -0
  352. data/test/MessageChannelTest.cpp +3 -3
  353. data/test/PoolOptionsTest.cpp +37 -0
  354. data/test/SpawnManagerTest.cpp +4 -4
  355. data/test/StandardApplicationPoolTest.cpp +4 -0
  356. data/test/SystemTimeTest.cpp +37 -0
  357. data/test/UtilsTest.cpp +137 -0
  358. data/test/integration_tests.rb +270 -23
  359. data/test/oxt/backtrace_test.cpp +128 -0
  360. data/test/oxt/oxt_test_main.cpp +25 -0
  361. data/test/oxt/syscall_interruption_test.cpp +50 -0
  362. data/test/ruby/abstract_request_handler_spec.rb +83 -0
  363. data/test/ruby/abstract_server_collection_spec.rb +246 -0
  364. data/test/ruby/application_spec.rb +3 -3
  365. data/test/ruby/message_channel_spec.rb +2 -2
  366. data/test/ruby/rack/application_spawner_spec.rb +3 -5
  367. data/test/ruby/rails/application_spawner_spec.rb +54 -15
  368. data/test/ruby/rails/framework_spawner_spec.rb +6 -8
  369. data/test/ruby/rails/minimal_spawner_spec.rb +29 -0
  370. data/test/ruby/rails/spawner_error_handling_spec.rb +1 -1
  371. data/test/ruby/rails/spawner_privilege_lowering_spec.rb +3 -3
  372. data/test/ruby/spawn_manager_spec.rb +23 -12
  373. data/test/ruby/utils_spec.rb +36 -2
  374. data/test/ruby/wsgi/application_spawner_spec.rb +47 -0
  375. data/test/stub/apache2/httpd.conf.erb +3 -5
  376. data/test/stub/message_channel.rb +2 -2
  377. data/test/stub/message_channel_2.rb +2 -2
  378. data/test/stub/message_channel_3.rb +3 -3
  379. data/test/stub/minimal-railsapp/README +0 -0
  380. data/test/stub/minimal-railsapp/config/application.rb +0 -0
  381. data/test/stub/minimal-railsapp/config/environment.rb +0 -0
  382. data/test/stub/minimal-railsapp/vendor/rails/actionmailer/lib/action_mailer.rb +0 -0
  383. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_controller.rb +0 -0
  384. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_pack.rb +0 -0
  385. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_view.rb +0 -0
  386. data/test/stub/minimal-railsapp/vendor/rails/activerecord/lib/active_record.rb +0 -0
  387. data/test/stub/minimal-railsapp/vendor/rails/activeresource/lib/active_resource.rb +0 -0
  388. data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support.rb +0 -0
  389. data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support/whiny_nil.rb +0 -0
  390. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/dispatcher.rb +0 -0
  391. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/initializer.rb +0 -0
  392. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/ruby_version_check.rb +0 -0
  393. data/test/stub/rails_apps/foobar/app/controllers/foo_controller.rb +8 -0
  394. data/test/stub/rails_apps/foobar/config/environments/development.rb +1 -2
  395. data/test/stub/rails_apps/mycook/app/controllers/welcome_controller.rb +21 -1
  396. data/test/stub/rails_apps/mycook/sites/some.site/public/uploads.html +26 -0
  397. data/test/stub/rails_apps/mycook/sites/some.site/public/welcome/cached.html +26 -0
  398. data/test/stub/railsapp/app/controllers/application.rb +0 -0
  399. data/test/stub/railsapp/app/controllers/bar_controller_1.rb +0 -0
  400. data/test/stub/railsapp/app/controllers/bar_controller_2.rb +1 -1
  401. data/test/stub/railsapp/app/controllers/foo_controller.rb +4 -0
  402. data/test/stub/railsapp/app/helpers/application_helper.rb +0 -0
  403. data/test/stub/railsapp/config/boot.rb +0 -0
  404. data/test/stub/railsapp/config/database.yml +0 -0
  405. data/test/stub/railsapp/config/environment.rb +0 -0
  406. data/test/stub/railsapp/config/environments/development.rb +0 -0
  407. data/test/stub/railsapp/config/environments/production.rb +0 -0
  408. data/test/stub/railsapp/config/initializers/inflections.rb +0 -0
  409. data/test/stub/railsapp/config/initializers/mime_types.rb +0 -0
  410. data/test/stub/railsapp/config/routes.rb +0 -0
  411. data/test/stub/railsapp/public/useless.txt +0 -0
  412. data/test/stub/spawn_server.rb +3 -4
  413. data/test/stub/wsgi/passenger_wsgi.pyc +0 -0
  414. data/test/support/apache2_controller.rb +57 -7
  415. data/test/support/tut.h +15 -0
  416. data/vendor/README +12 -0
  417. data/vendor/README_FOR_PACKAGERS +1 -0
  418. data/vendor/rack-0.9.1/AUTHORS +8 -0
  419. data/vendor/rack-0.9.1/COPYING +18 -0
  420. data/vendor/rack-0.9.1/ChangeLog +1423 -0
  421. data/vendor/rack-0.9.1/KNOWN-ISSUES +18 -0
  422. data/vendor/rack-0.9.1/README +306 -0
  423. data/vendor/rack-0.9.1/Rakefile +188 -0
  424. data/vendor/rack-0.9.1/SPEC +129 -0
  425. data/vendor/rack-0.9.1/lib/rack.rb +86 -0
  426. data/vendor/rack-0.9.1/lib/rack/adapter/camping.rb +22 -0
  427. data/vendor/rack-0.9.1/lib/rack/auth/abstract/handler.rb +28 -0
  428. data/vendor/rack-0.9.1/lib/rack/auth/abstract/request.rb +37 -0
  429. data/vendor/rack-0.9.1/lib/rack/auth/basic.rb +58 -0
  430. data/vendor/rack-0.9.1/lib/rack/auth/digest/md5.rb +124 -0
  431. data/vendor/rack-0.9.1/lib/rack/auth/digest/nonce.rb +51 -0
  432. data/vendor/rack-0.9.1/lib/rack/auth/digest/params.rb +55 -0
  433. data/vendor/rack-0.9.1/lib/rack/auth/digest/request.rb +40 -0
  434. data/vendor/rack-0.9.1/lib/rack/auth/openid.rb +438 -0
  435. data/vendor/rack-0.9.1/lib/rack/builder.rb +67 -0
  436. data/vendor/rack-0.9.1/lib/rack/cascade.rb +36 -0
  437. data/vendor/rack-0.9.1/lib/rack/commonlogger.rb +61 -0
  438. data/vendor/rack-0.9.1/lib/rack/conditionalget.rb +43 -0
  439. data/vendor/rack-0.9.1/lib/rack/content_length.rb +25 -0
  440. data/vendor/rack-0.9.1/lib/rack/deflater.rb +87 -0
  441. data/vendor/rack-0.9.1/lib/rack/directory.rb +150 -0
  442. data/vendor/rack-0.9.1/lib/rack/file.rb +85 -0
  443. data/vendor/rack-0.9.1/lib/rack/handler.rb +48 -0
  444. data/vendor/rack-0.9.1/lib/rack/handler/cgi.rb +57 -0
  445. data/vendor/rack-0.9.1/lib/rack/handler/evented_mongrel.rb +8 -0
  446. data/vendor/rack-0.9.1/lib/rack/handler/fastcgi.rb +86 -0
  447. data/vendor/rack-0.9.1/lib/rack/handler/lsws.rb +52 -0
  448. data/vendor/rack-0.9.1/lib/rack/handler/mongrel.rb +82 -0
  449. data/vendor/rack-0.9.1/lib/rack/handler/scgi.rb +57 -0
  450. data/vendor/rack-0.9.1/lib/rack/handler/swiftiplied_mongrel.rb +8 -0
  451. data/vendor/rack-0.9.1/lib/rack/handler/thin.rb +15 -0
  452. data/vendor/rack-0.9.1/lib/rack/handler/webrick.rb +61 -0
  453. data/vendor/rack-0.9.1/lib/rack/head.rb +19 -0
  454. data/vendor/rack-0.9.1/lib/rack/lint.rb +465 -0
  455. data/vendor/rack-0.9.1/lib/rack/lobster.rb +65 -0
  456. data/vendor/rack-0.9.1/lib/rack/methodoverride.rb +27 -0
  457. data/vendor/rack-0.9.1/lib/rack/mime.rb +204 -0
  458. data/vendor/rack-0.9.1/lib/rack/mock.rb +160 -0
  459. data/vendor/rack-0.9.1/lib/rack/recursive.rb +57 -0
  460. data/vendor/rack-0.9.1/lib/rack/reloader.rb +64 -0
  461. data/vendor/rack-0.9.1/lib/rack/request.rb +218 -0
  462. data/vendor/rack-0.9.1/lib/rack/response.rb +171 -0
  463. data/vendor/rack-0.9.1/lib/rack/session/abstract/id.rb +153 -0
  464. data/vendor/rack-0.9.1/lib/rack/session/cookie.rb +89 -0
  465. data/vendor/rack-0.9.1/lib/rack/session/memcache.rb +97 -0
  466. data/vendor/rack-0.9.1/lib/rack/session/pool.rb +73 -0
  467. data/vendor/rack-0.9.1/lib/rack/showexceptions.rb +348 -0
  468. data/vendor/rack-0.9.1/lib/rack/showstatus.rb +106 -0
  469. data/vendor/rack-0.9.1/lib/rack/static.rb +38 -0
  470. data/vendor/rack-0.9.1/lib/rack/urlmap.rb +48 -0
  471. data/vendor/rack-0.9.1/lib/rack/utils.rb +347 -0
  472. metadata +1197 -1055
  473. data/doc/cxxapi/System_8h-source.html +0 -251
  474. data/doc/cxxapi/classDirectoryMapper-members.html +0 -38
  475. data/doc/cxxapi/classDirectoryMapper.html +0 -203
  476. data/doc/cxxapi/classPassenger_1_1Thread.html +0 -100
  477. data/doc/cxxapi/classboost_1_1this__thread_1_1disable__syscall__interruption.html +0 -46
  478. data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption-members.html +0 -33
  479. data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption.html +0 -44
  480. data/doc/cxxapi/namespacePassenger.html +0 -208
  481. data/doc/cxxapi/namespacePassenger_1_1InterruptableCalls.html +0 -43
  482. data/doc/cxxapi/namespacemembers.html +0 -70
  483. data/doc/cxxapi/namespacemembers_func.html +0 -66
  484. data/doc/cxxapi/namespacemembers_type.html +0 -46
  485. data/doc/cxxapi/namespaces.html +0 -35
  486. data/doc/rdoc/classes/Passenger.html +0 -136
  487. data/doc/rdoc/classes/Passenger/AbstractRequestHandler.html +0 -402
  488. data/doc/rdoc/classes/Passenger/SpawnManager.html +0 -379
  489. data/doc/rdoc/classes/Passenger/Utils.html +0 -578
  490. data/ext/apache2/System.h +0 -228
  491. data/lib/passenger/platform_info.rb +0 -302
  492. data/lib/passenger/templates/app_exited_during_initialization.html.erb +0 -19
  493. data/test/stub/apache2/httpd.conf +0 -75
  494. data/test/stub/rails_apps/foobar/config/environments/test.rb +0 -22
  495. data/test/stub/rails_apps/mycook/config/environments/test.rb +0 -22
  496. data/test/stub/railsapp/config/environments/test.rb +0 -22
  497. data/test/stub/railsapp2/config/environments/test.rb +0 -22
@@ -28,6 +28,7 @@ Phusion Passenger has been tested on:
28
28
 
29
29
  - Ubuntu Linux 6.06 (x86)
30
30
  - Ubuntu Linux 7.10 (x86)
31
+ - Ubuntu Linux 8.04 (x86)
31
32
  - Debian Sarge (x86)
32
33
  - Debian Etch (x86)
33
34
  - Debian Lenny/Sid (x86)
@@ -131,22 +132,19 @@ passenger-install-apache2-module
131
132
  ------------------------------------------------------
132
133
  Please follow the instructions given by the installer.
133
134
 
135
+
134
136
  ==== Installing via a native Linux package ====
135
137
 
136
- Please install the native Linux package, e.g.:
137
- ------------------------------------------------------
138
- gdebi passenger_x.x.x-i386.deb
139
- ------------------------------------------------------
138
+ John Leach from Brightbox has kindly provided an Ubuntu Hardy package for Phusion Passenger. The package is available from the link:http://apt.brightbox.net[Brightbox repository].
140
139
 
141
- Next, you'll need to configure Apache. Run the "installer", as it will tell you
142
- the correct configuration options for Apache:
140
+ Please install the native Linux package, e.g.:
143
141
  ------------------------------------------------------
144
- passenger-install-apache2-module
142
+ sudo sh -c 'echo "deb http://apt.brightbox.net hardy main" > /etc/apt/sources.list.d/brightbox.list'
143
+ sudo sh -c 'wget -q -O - http://apt.brightbox.net/release.asc | apt-key add -'
144
+ sudo apt-get update
145
+ sudo apt-get install libapache2-mod-passenger
145
146
  ------------------------------------------------------
146
147
 
147
- NOTE: The installer doesn't actually install anything because it will automatically
148
- detect that Phusion Passenger has already been installed. The only thing the
149
- installer will do in this case, is showing the correct Apache configurations.
150
148
 
151
149
  ==== Installing via the source tarball ====
152
150
 
@@ -260,8 +258,8 @@ There are two ways to restart the application:
260
258
 
261
259
  1. By restarting Apache.
262
260
  2. By creating or modifying the file 'tmp/restart.txt' in the Rails
263
- application's root folder. Phusion Passenger will automatically
264
- restart the application.
261
+ application's <<application_root,root folder>>. Phusion Passenger will
262
+ automatically restart the application.
265
263
 
266
264
  For example, to restart our example MyCook application, we type this in the
267
265
  command line:
@@ -288,7 +286,7 @@ link:http://rack.rubyforge.org/[Rack] interface.
288
286
 
289
287
  Phusion Passenger assumes that Rack application directories have a certain layout.
290
288
  Suppose that you have a Rack application in '/webapps/rackapp'. Then that
291
- folder must contain at least two entries:
289
+ folder must contain at least three entries:
292
290
 
293
291
  - 'config.ru', a Rackup file for starting the Rack application. This file must contain
294
292
  the complete logic for initializing the application.
@@ -419,8 +417,8 @@ There are two ways to restart the application:
419
417
 
420
418
  1. By restarting Apache.
421
419
  2. By creating or modifying the file 'tmp/restart.txt' in the Rack
422
- application's root folder. Phusion Passenger will automatically restart the
423
- application.
420
+ application's <<application_root,root folder>>. Phusion Passenger will
421
+ automatically restart the application.
424
422
 
425
423
  For example, to restart our example application, we type this in the
426
424
  command line:
@@ -472,8 +470,10 @@ run Mack::Utils::Server.build_app
472
470
  require 'rubygems'
473
471
  require 'merb-core'
474
472
 
475
- Merb::Config.setup(:merb_root => ".",
476
- :environment => ENV['RACK_ENV'])
473
+ Merb::Config.setup(
474
+ :merb_root => File.expand_path(File.dirname(__FILE__)),
475
+ :environment => ENV['RACK_ENV']
476
+ )
477
477
  Merb.environment = Merb::Config[:environment]
478
478
  Merb.root = Merb::Config[:merb_root]
479
479
  Merb::BootLoader.run
@@ -496,14 +496,12 @@ require 'sinatra'
496
496
 
497
497
  root_dir = File.dirname(__FILE__)
498
498
 
499
- Sinatra::Application.default_options.merge!(
500
- :views => File.join(root_dir, 'views'),
501
- :app_file => File.join(root_dir, 'app.rb'),
502
- :run => false,
503
- :env => ENV['RACK_ENV'].to_sym
504
- )
499
+ set :environment, ENV['RACK_ENV'].to_sym
500
+ set :root, root_dir
501
+ set :app_file, File.join(root_dir, 'app.rb')
502
+ disable :run
505
503
 
506
- run Sinatra.application
504
+ run Sinatra::Application
507
505
  ------------------------------------------------------
508
506
 
509
507
 
@@ -545,12 +543,43 @@ This option allows one to specify the Ruby interpreter to use.
545
543
  This option may only occur once, in the global server configuration.
546
544
  The default is 'ruby'.
547
545
 
546
+ [[PassengerAppRoot]]
547
+ === PassengerAppRoot <path/to/root> ===
548
+ By default, Phusion Passenger assumes that the application's root directory
549
+ is the parent directory of the 'public' directory. This option allows one to
550
+ specify the application's root independently from the DocumentRoot, which
551
+ is useful if the 'public' directory lives in a non-standard place.
552
+
553
+ This option may occur in the following places:
554
+
555
+ * In the global server configuration.
556
+ * In a virtual host configuration block.
557
+ * In a `<Directory>` or `<Location>` block.
558
+ * In '.htaccess', if `AllowOverride Options` is on.
559
+
560
+ In each place, it may be specified at most once.
561
+
562
+ Example:
563
+
564
+ -----------------------------
565
+ <VirtualHost test.host>
566
+ DocumentRoot /var/rails/zena/sites/example.com/public
567
+ PassengerAppRoot /var/rails/zena # <-- normally Phusion Passenger would
568
+ # have assumed that the application
569
+ # root is "/var/rails/zena/sites/example.com"
570
+ </VirtualHost>
571
+ -----------------------------
572
+
548
573
  [[PassengerUseGlobalQueue]]
549
574
  === PassengerUseGlobalQueue <on|off> ===
550
575
  Turns the use of global queuing on or off.
551
576
 
552
- This option may only occur once, in the global server configuration. The
553
- default is 'off'.
577
+ This option may occur in the following places:
578
+
579
+ * In the global server configuration.
580
+ * In a virtual host configuration block.
581
+
582
+ In each place, it may be specified at most once. The default value is 'off'.
554
583
 
555
584
  'This feature is sponsored by http://www.37signals.com/[37signals].'
556
585
 
@@ -650,6 +679,197 @@ applications must run as, if user switching fails or is disabled.
650
679
  This option may only occur once, in the global server configuration.
651
680
  The default value is 'nobody'.
652
681
 
682
+ [[PassengerHighPerformance]]
683
+ === PassengerHighPerformance <on|off> ===
684
+ By default, Phusion Passenger is compatible with mod_rewrite and most other
685
+ Apache modules. However, a lot of effort is required in order to be compatible.
686
+ If you turn 'PassengerHighPerformance' to 'on', then Phusion Passenger will be
687
+ a little faster, in return for reduced compatibility with other Apache modules.
688
+
689
+ In places where 'PassengerHighPerformance' is turned on, mod_rewrite rules will
690
+ likely not work. mod_autoindex (the module which displays a directory index)
691
+ will also not work. Other Apache modules may or may not work, depending on what
692
+ they exactly do. We recommend you to find out how other modules behave in high
693
+ performance mode via testing.
694
+
695
+ This option is *not* an all-or-nothing global option: you can enable high
696
+ performance mode for certain virtual hosts or certain URLs only.
697
+ The 'PassengerHighPerformance' option may occur in the following places:
698
+
699
+ * In the global server configuration.
700
+ * In a virtual host configuration block.
701
+ * In a `<Directory>` or `<Location>` block.
702
+ * In '.htaccess'.
703
+
704
+ In each place, it may be specified at most once. The default value is 'off',
705
+ so high performance mode is disabled by default, and you have to explicitly
706
+ enable it.
707
+
708
+ .When to enable high performance mode?
709
+
710
+ If you do not use mod_rewrite or other Apache modules then it might make
711
+ sense to enable high performance mode.
712
+
713
+ It's likely that some of your applications depend on mod_rewrite or other
714
+ Apache modules, while some do not. In that case you can enable high performance
715
+ for only those applications that don't use other Apache modules. For example:
716
+
717
+ ------------------------------------
718
+ <VirtualHost *:80>
719
+ ServerName www.foo.com
720
+ DocumentRoot /apps/foo/public
721
+ .... mod_rewrite rules or options for other Apache modules here ...
722
+ </VirtualHost>
723
+
724
+ <VirtualHost *:80>
725
+ ServerName www.bar.com
726
+ DocumentRoot /apps/bar/public
727
+ PassengerHighPerformance on
728
+ </VirtualHost>
729
+ ------------------------------------
730
+
731
+ In the above example, high performance mode is only enabled for www.bar.com.
732
+ It is disabled for everything else.
733
+
734
+ If your application generally depends on mod_rewrite or other Apache modules,
735
+ but a certain URL that's accessed often doesn't depend on those other modules,
736
+ then you can enable high performance mode for a certain URL only. For example:
737
+
738
+ ------------------------------------
739
+ <VirtualHost *:80>
740
+ ServerName www.foo.com
741
+ DocumentRoot /apps/foo/public
742
+ .... mod_rewrite rules or options for other Apache modules here ...
743
+
744
+ <Location /chatroom/ajax_update_poll>
745
+ PassengerHighPerformance on
746
+ </Location>
747
+ </VirtualHost>
748
+ ------------------------------------
749
+
750
+ This enables high performance mode for
751
+ http://www.foo.com/chatroom/ajax_update_poll only.
752
+
753
+ === PassengerEnabled <on|off> ===
754
+ You can set this option to 'off' to completely disable Phusion Passenger for
755
+ a certain location. This is useful if, for example, you want to integrate a PHP
756
+ application into the same virtual host as a Rails application.
757
+
758
+ Suppose that you have a Rails application in '/apps/foo'. Suppose that you've
759
+ dropped Wordpress -- a blogging application written in PHP -- in
760
+ '/apps/foo/public/wordpress'. You can then configure Phusion Passenger as
761
+ follows:
762
+
763
+ ------------------------------------
764
+ <VirtualHost *:80>
765
+ ServerName www.foo.com
766
+ DocumentRoot /apps/foo/public
767
+ <Location /wordpress>
768
+ PassengerEnabled off
769
+ AllowOverride all # <-- Makes Wordpress's .htaccess file work.
770
+ </Location>
771
+ </VirtualHost>
772
+ ------------------------------------
773
+
774
+ This way, Phusion Passenger will not interfere with Wordpress.
775
+
776
+ 'PassengerEnabled' may occur in the following places:
777
+
778
+ * In the global server configuration.
779
+ * In a virtual host configuration block.
780
+ * In a `<Directory>` or `<Location>` block.
781
+ * In '.htaccess'.
782
+
783
+ In each place, it may be specified at most once. The default value is 'on'.
784
+
785
+ === PassengerTempDir <directory> ===
786
+ Specifies the directory that Phusion Passenger should use for storing temporary
787
+ files. This includes things such as Unix socket files, buffered file uploads,
788
+ etc.
789
+
790
+ This option may be specified once, in the global server configuration. The
791
+ default temp directory that Phusion Passenger uses is '/tmp'.
792
+
793
+ This option is especially useful if Apache is not allowed to write to /tmp
794
+ (which is the case on some systems with strict SELinux policies) or if the
795
+ partition that /tmp lives on doesn't have enough disk space.
796
+
797
+ .Command line tools
798
+ Some Phusion Passenger command line administration tools, such as
799
+ `passenger-status`, must know what Phusion Passenger's temp directory is
800
+ in order to function properly. You can pass the directory through the
801
+ `PASSENGER_TMPDIR` environment variable, or the `TMPDIR` environment variable
802
+ (the former will be used if both are specified).
803
+
804
+ For example, if you set 'PassengerTempDir' to '/my_temp_dir', then invoke
805
+ `passenger-status` after you've set the `PASSENGER_TMPDIR` or `TMPDIR`
806
+ environment variable, like this:
807
+
808
+ ----------------------------------------------------------
809
+ export PASSENGER_TMPDIR=/my_temp-dir
810
+ sudo -E passenger-status
811
+ # The -E option tells 'sudo' to preserve environment variables.
812
+ ----------------------------------------------------------
813
+
814
+ === PassengerRestartDir <directory> ===
815
+ As described in the deployment chapters of this document, Phusion Passenger
816
+ checks the file 'tmp/restart.txt' in the applications'
817
+ <<application_root,root directory>> for restarting applications. Sometimes it
818
+ may be desirable for Phusion Passenger to look in a different directory instead,
819
+ for example for security reasons (see below). This option allows you to
820
+ customize the directory in which 'restart.txt' is searched for.
821
+
822
+ You may specify 'PassengerRestartDir' in the following places:
823
+
824
+ * In the global server configuration.
825
+ * In a virtual host configuration block.
826
+ * In a `<Directory>` or `<Location>` block.
827
+ * In '.htaccess', if `AllowOverrides Options` is enabled.
828
+
829
+ In each place, it may be specified at most once.
830
+
831
+ You can either set it to an absolute directory, or to a directory relative to
832
+ the <<application_root,application root>>. Examples:
833
+
834
+ -----------------------------------
835
+ <VirtualHost *:80>
836
+ ServerName www.foo.com
837
+ # Phusion Passenger will check for /apps/foo/public/tmp/restart.txt
838
+ DocumentRoot /apps/foo/public
839
+ </VirtualHost>
840
+
841
+ <VirtualHost *:80>
842
+ ServerName www.bar.com
843
+ DocumentRoot /apps/bar/public
844
+ # An absolute filename is given; Phusion Passenger will
845
+ # check for /restart_files/bar/restart.txt
846
+ PassengerRestartDir /restart_files/bar
847
+ </VirtualHost>
848
+
849
+ <VirtualHost *:80>
850
+ ServerName www.baz.com
851
+ DocumentRoot /apps/baz/public
852
+ # A relative filename is given; Phusion Passenger will
853
+ # check for /apps/baz/restart_files/restart.txt
854
+ #
855
+ # Note that this directory is relative to the APPLICATION ROOT, *not*
856
+ # the value of DocumentRoot!
857
+ PassengerRestartDir restart_files
858
+ </VirtualHost>
859
+ -----------------------------------
860
+
861
+ .What are the security reasons for wanting to customize PassengerRestartDir?
862
+ Touching restart.txt will cause Phusion Passenger to restart the application.
863
+ So anybody who can touch restart.txt can effectively cause a Denial-of-Service
864
+ attack by touching restart.txt over and over. If your web server or one of your
865
+ web applications has the permission to touch restart.txt, and one of them has a
866
+ security flaw which allows an attacker to touch restart.txt, then that will
867
+ allow the attacker to cause a Denial-of-Service.
868
+
869
+ You can prevent this from happening by pointing PassengerRestartDir to a
870
+ directory that's readable by Apache, but only writable by administrators.
871
+
872
+
653
873
  === Resource control and optimization options ===
654
874
 
655
875
  ==== PassengerMaxPoolSize <integer> ====
@@ -705,9 +925,75 @@ Rails/Rack web page. We recommend a value of `2 * x`, where `x` is the average
705
925
  number of seconds that a visitor spends on a single Rails/Rack web page. But your
706
926
  mileage may vary.
707
927
 
928
+ When this value is set to '0', application instances will not be shutdown unless
929
+ it's really necessary, i.e. when Phusion Passenger is out of worker processes
930
+ for a given application and one of the inactive application instances needs to
931
+ make place for another application instance. Setting the value to 0 is
932
+ recommended if you're on a non-shared host that's only running a few
933
+ applications, each which must be available at all times.
934
+
708
935
  This option may only occur once, in the global server configuration.
709
936
  The default value is '300'.
710
937
 
938
+ [[PassengerMaxRequests]]
939
+ ==== PassengerMaxRequests <integer> ====
940
+ The maximum number of requests an application instance will process. After
941
+ serving that many requests, the application instance will be shut down and
942
+ Phusion Passenger will restart it. A value of 0 means that there is no maximum:
943
+ an application instance will thus be shut down when its idle timeout has been
944
+ reached.
945
+
946
+ This option is useful if your application is leaking memory. By shutting
947
+ it down after a certain number of requests, all of its memory is guaranteed
948
+ to be freed by the operating system.
949
+
950
+ This option may occur in the following places:
951
+
952
+ * In the global server configuration.
953
+ * In a virtual host configuration block.
954
+ * In a `<Directory>` or `<Location>` block.
955
+ * In '.htaccess', if `AllowOverride Limits` is on.
956
+
957
+ In each place, it may be specified at most once. The default value is '0'.
958
+
959
+ [CAUTION]
960
+ =====================================================
961
+ The <<PassengerMaxRequests,PassengerMaxRequests>> directive should be considered
962
+ as a workaround for misbehaving applications. It is advised that you fix the
963
+ problem in your application rather than relying on these directives as a
964
+ measure to avoid memory leaks.
965
+ =====================================================
966
+
967
+ ==== PassengerStatThrottleRate <integer> ====
968
+ By default, Phusion Passenger performs several filesystem checks (or, in
969
+ programmers jargon, 'stat() calls') each time a request is processed:
970
+
971
+ - It checks whether 'config/environment.rb', 'config.ru' or 'passenger_wsgi.py'
972
+ is present, in order to autodetect Rails, Rack and WSGI applications.
973
+ - It checks whether 'restart.txt' has changed or whether 'always_restart.txt'
974
+ exists, in order to determine whether the application should be restarted.
975
+
976
+ On some systems where disk I/O is expensive, e.g. systems where the harddisk is
977
+ already being heavily loaded, or systems where applications are stored on NFS
978
+ shares, these filesystem checks can incur a lot of overhead.
979
+
980
+ You can decrease or almost entirely eliminate this overhead by setting
981
+ 'PassengerStatThrottleRate'. Setting this option to a value of 'x' means that
982
+ the above list of filesystem checks will be performed at most once every 'x'
983
+ seconds. Setting it to a value of '0' means that no throttling will take place,
984
+ or in other words, that the above list of filesystem checks will be performed on
985
+ every request.
986
+
987
+ This option may occur in the following places:
988
+
989
+ * In the global server configuration.
990
+ * In a virtual host configuration block.
991
+ * In a `<Directory>` or `<Location>` block.
992
+ * In '.htaccess', if `AllowOverride Limits` is on.
993
+
994
+ In each place, it may be specified at most once. The default value is '0'.
995
+
996
+
711
997
  === Ruby on Rails-specific options ===
712
998
 
713
999
  ==== RailsAutoDetect <on|off> ====
@@ -751,23 +1037,25 @@ Used to specify that the given URI is a Rails application. See
751
1037
  It is allowed to specify this option multiple times. Do this to deploy multiple
752
1038
  Rails applications in different sub-URIs under the same virtual host.
753
1039
 
754
- This option may occur in the global server configuration or in a
755
- virtual host configuration block.
756
-
757
- [[RailsAllowModRewrite]]
758
- ==== RailsAllowModRewrite <on|off> ====
759
- If enabled, Phusion Passenger will not override mod_rewrite rules. Please read
760
- <<conflicting_apache_modules,Conflicting Apache modules>> for details.
1040
+ This option may occur in the following places:
761
1041
 
762
- This option may occur once, in the global server configuration or in a virtual host
763
- configuration block. The default value is 'off'.
1042
+ * In the global server configuration.
1043
+ * In a virtual host configuration block.
1044
+ * In a `<Directory>` or `<Location>` block.
1045
+ * In '.htaccess', if `AllowOverride Options` is on.
764
1046
 
765
1047
  [[rails_env]]
766
1048
  ==== RailsEnv <string> ====
767
1049
  This option allows one to specify the default `RAILS_ENV` value.
768
1050
 
769
- This option may occur once, in the global server configuration or in a virtual host
770
- configuration block. The default value is 'production'.
1051
+ This option may occur in the following places:
1052
+
1053
+ * In the global server configuration.
1054
+ * In a virtual host configuration block.
1055
+ * In a `<Directory>` or `<Location>` block.
1056
+ * In '.htaccess', if `AllowOverride Options` is on.
1057
+
1058
+ In each place, it may be specified at most once. The default value is 'production'.
771
1059
 
772
1060
  [[RailsSpawnMethod]]
773
1061
  ==== RailsSpawnMethod <string> ====
@@ -779,11 +1067,11 @@ understand it, as it's mostly a technical detail. You can basically follow this
779
1067
 
780
1068
  ************************************************
781
1069
  If your application works on Mongrel, but not on Phusion Passenger, then set
782
- `RailsSpawnMethod` to 'conservative'. Otherwise, leave it at 'smart' (the default).
1070
+ `RailsSpawnMethod` to 'conservative'. Otherwise, leave it at 'smart-lv2' (the default).
783
1071
  ************************************************
784
1072
 
785
- However, we do recommend you to try to understand it. The 'smart' spawn method brings
786
- many benefits.
1073
+ However, we do recommend you to try to understand it. The 'smart' and 'smart-lv2' spawn
1074
+ methods bring many benefits.
787
1075
  =========================================================
788
1076
 
789
1077
  Internally, Phusion Passenger spawns multiple Ruby on Rails processes in order to handle
@@ -792,7 +1080,9 @@ its own set of pros and cons. Supported spawn methods are:
792
1080
 
793
1081
  'smart'::
794
1082
  When this spawn method is used, Phusion Passenger will attempt to cache Ruby on Rails
795
- framework code and application code for a limited period of time.
1083
+ framework code and application code for a limited period of time. Please read
1084
+ <<spawning_methods_explained,Spawning methods explained>> for a more detailed
1085
+ explanation of what smart spawning exactly does.
796
1086
  +
797
1087
  *Pros:*
798
1088
  This can significantly decrease spawn time (by as much as 90%). And, when Ruby Enterprise
@@ -803,9 +1093,26 @@ Some Ruby on Rails applications and libraries are not compatible with smart spaw
803
1093
  If that's the case for your application, then you should use 'conservative' as
804
1094
  spawning method.
805
1095
 
1096
+ 'smart-lv2'::
1097
+ This spawning method is similar to 'smart' but it skips the framework spawner
1098
+ and uses the application spawner directly. This means the framework code is not
1099
+ cached between multiple applications, although it is still cached within
1100
+ instances of the same application. Please read
1101
+ <<spawning_methods_explained,Spawning methods explained>> for a more detailed
1102
+ explanation of what smart-lv2 spawning exactly does.
1103
+ +
1104
+ *Pros:* It is compatible with a larger number of applications when compared to
1105
+ the 'smart' method, and still performs some caching.
1106
+ +
1107
+ *Cons:* It is slower than smart spawning if you have many applications which
1108
+ use the same framework version. It is therefore advised that shared hosts use the
1109
+ 'smart' method instead.
1110
+
806
1111
  'conservative'::
807
- This spawning method is similar to the one used in Mongrel Cluster. It does not perform
808
- any code caching at all.
1112
+ This spawning method is similar to the one used in Mongrel Cluster. It does not
1113
+ perform any code caching at all. Please read
1114
+ <<spawning_methods_explained,Spawning methods explained>> for a more detailed
1115
+ explanation of what conservative spawning exactly does.
809
1116
  +
810
1117
  *Pros:*
811
1118
  Conservative spawning is guaranteed to be compatible with all Rails applications
@@ -816,8 +1123,52 @@ Much slower than smart spawning. Every spawn action will be equally slow, though
816
1123
  the startup time of a single server in Mongrel Cluster. Conservative spawning will also
817
1124
  render <<reducing_memory_usage,Ruby Enterprise Edition's memory reduction technology>> useless.
818
1125
 
819
- This option may occur once, in the global server configuration or in a virtual host
820
- configuration block. The default value is 'smart'.
1126
+ This option may occur in the following places:
1127
+
1128
+ * In the global server configuration.
1129
+ * In a virtual host configuration block.
1130
+
1131
+ In each place, it may be specified at most once. The default value is 'smart-lv2'.
1132
+
1133
+ ==== RailsFrameworkSpawnerIdleTime <integer> ====
1134
+ The FrameworkSpawner server (explained in <<spawning_methods_explained,Spawning
1135
+ methods explained>>) has an idle timeout, just like the backend processes spawned by
1136
+ Phusion Passenger do. That is, it will automatically shutdown if it hasn't done
1137
+ anything for a given period.
1138
+
1139
+ This option allows you to set the FrameworkSpawner server's idle timeout, in
1140
+ seconds. A value of '0' means that it should never idle timeout.
1141
+
1142
+ Setting a higher value will mean that the FrameworkSpawner server is kept around
1143
+ longer, which may slightly increase memory usage. But as long as the
1144
+ FrameworkSpawner server is running, the time to spawn a Ruby on Rails backend
1145
+ process only takes about 40% of the time that is normally needed, assuming that
1146
+ you're using the 'smart' <<RailsSpawnMethod,spawning method>>. So if your
1147
+ system has enough memory, is it recommended that you set this option to a high
1148
+ value or to '0'.
1149
+
1150
+ This option may only occur in the global server configuration, and may occur at
1151
+ most once. The default value is '1800' (30 minutes).
1152
+
1153
+ ==== RailsAppSpawnerIdleTime <integer> ====
1154
+ The ApplicationSpawner server (explained in <<spawning_methods_explained,Spawning
1155
+ methods explained>>) has an idle timeout, just like the backend processes spawned by
1156
+ Phusion Passenger do. That is, it will automatically shutdown if it hasn't done
1157
+ anything for a given period.
1158
+
1159
+ This option allows you to set the ApplicationSpawner server's idle timeout, in
1160
+ seconds. A value of '0' means that it should never idle timeout.
1161
+
1162
+ Setting a higher value will mean that the ApplicationSpawner server is kept around
1163
+ longer, which may slightly increase memory usage. But as long as the
1164
+ ApplicationSpawner server is running, the time to spawn a Ruby on Rails backend
1165
+ process only takes about 10% of the time that is normally needed, assuming that
1166
+ you're using the 'smart' or 'smart-lv2' <<RailsSpawnMethod,spawning method>>. So if your
1167
+ system has enough memory, is it recommended that you set this option to a high
1168
+ value or to '0'.
1169
+
1170
+ This option may only occur in the global server configuration, and may occur at
1171
+ most once. The default value is '600' (10 minutes).
821
1172
 
822
1173
  === Rack-specific options ===
823
1174
 
@@ -862,8 +1213,12 @@ Used to specify that the given URI is a Rack application. See
862
1213
  It is allowed to specify this option multiple times. Do this to deploy multiple
863
1214
  Rack applications in different sub-URIs under the same virtual host.
864
1215
 
865
- This option may occur in the global server configuration or in a
866
- virtual host configuration block.
1216
+ This option may occur in the following places:
1217
+
1218
+ * In the global server configuration.
1219
+ * In a virtual host configuration block.
1220
+ * In a `<Directory>` or `<Location>` block.
1221
+ * In '.htaccess', if `AllowOverride Options` is on.
867
1222
 
868
1223
  [[rack_env]]
869
1224
  ==== RackEnv <string> ====
@@ -871,8 +1226,14 @@ The given value will be accessible in Rack applications in the `RACK_ENV`
871
1226
  environment variable. This allows one to define the environment in which
872
1227
  Rack applications are run, very similar to `RAILS_ENV`.
873
1228
 
874
- This option may occur once, in the global server configuration or in a virtual host
875
- configuration block. The default value is 'production'.
1229
+ This option may occur in the following places:
1230
+
1231
+ * In the global server configuration.
1232
+ * In a virtual host configuration block.
1233
+ * In a `<Directory>` or `<Location>` block.
1234
+ * In '.htaccess', if `AllowOverride Options` is on.
1235
+
1236
+ In each place, it may be specified at most once. The default value is 'production'.
876
1237
 
877
1238
  === Deprecated options ===
878
1239
 
@@ -888,6 +1249,9 @@ Deprecated in favor of <<PassengerUserSwitching,PassengerUserSwitching>>.
888
1249
  ==== RailsDefaultUser ====
889
1250
  Deprecated in favor of <<PassengerDefaultUser,PassengerDefaultUser>>.
890
1251
 
1252
+ ==== RailsAllowModRewrite ====
1253
+ This option doesn't do anything anymore in recent versions of Phusion Passenger.
1254
+
891
1255
 
892
1256
  == Troubleshooting ==
893
1257
 
@@ -1197,34 +1561,6 @@ chcon -R -h -t httpd_sys_content_t /path/to/your/rails/app
1197
1561
  [[conflicting_apache_modules]]
1198
1562
  === Conflicting Apache modules ===
1199
1563
 
1200
- ==== mod_rewrite and mod_alias ====
1201
-
1202
- Phusion Passenger conflicts with 'mod_rewrite' and 'mod_alias'. Those modules may be
1203
- installed and loaded together with 'mod_passenger', and they will work fine
1204
- outside virtual hosts that contain a Rails application, but we recommend you
1205
- not to use their features inside virtual hosts that contain a Rails
1206
- application.
1207
-
1208
- By default, Phusion Passenger will override mod_rewrite rules on Rails hosts.
1209
- This is because the default .htaccess, as provided by Ruby on Rails, redirects all
1210
- requests to `dispatch.cgi' using mod_rewrite. This is a CGI application which
1211
- loads the entire Ruby on Rails framework for every request, and thus is very
1212
- slow. If we do not override mod_rewrite, then Ruby on Rails apps will be slow
1213
- on Phusion Passenger by default -- but we want a good out-of-the-box experience.
1214
-
1215
- Furthermore, the primary reason why people use mod_rewrite with Rails
1216
- applications, is to accelerate page caching. Phusion Passenger supports page
1217
- caching out-of-the-box, without mod_rewrite.
1218
-
1219
- It is not fully understood how mod_alias conflicts with Phusion Passenger, but we
1220
- recommend you not to use it on Rails virtual hosts. mod_alias rules can result
1221
- in surprising problems.
1222
-
1223
- If you really want to use mod_rewrite on Rails virtual hosts, then please set
1224
- the <<RailsAllowModRewrite,RailsAllowModRewrite>> configuration option. But
1225
- please note that you will have to delete Rails applications' default .htaccess
1226
- file, or add rewrite rules to negate its effects.
1227
-
1228
1564
  ==== mod_userdir ====
1229
1565
 
1230
1566
  'mod_userdir' is not compatible with Phusion Passenger at the moment.
@@ -1302,9 +1638,9 @@ count = 1
1302
1638
  active = 0
1303
1639
  inactive = 1
1304
1640
 
1305
- ----------- Applications -----------
1641
+ ----------- Domains -----------
1306
1642
  /var/www/projects/app1-foobar:
1307
- PID: 9617 Sessions: 0
1643
+ PID: 9617 Sessions: 0 Processed: 7 Uptime: 2m 23s
1308
1644
  --------------------------------------------------
1309
1645
 
1310
1646
  The 'general information' section shows the following information:
@@ -1317,30 +1653,39 @@ active:: The number of application instances that are currently processing
1317
1653
  requests. This value is always less than or equal to 'count'.
1318
1654
  inactive:: The number of application instances that are currently *not* processing
1319
1655
  requests, i.e. are idle. Idle application instances will be shutdown after a while,
1320
- as can be specified with <<PassengerPoolIdleTime,PassengerPoolIdleTime>>. The value of 'inactive'
1321
- equals `count - active`.
1656
+ as can be specified with <<PassengerPoolIdleTime,PassengerPoolIdleTime>> (unless this
1657
+ value is set to 0, in which case application instances are never shut down via idle
1658
+ time). The value of 'inactive' equals `count - active`.
1659
+
1660
+ The 'domains' section shows, for each application directory, information about running
1661
+ application instances:
1322
1662
 
1323
- The 'applications' section shows each application instance, which directory it belongs
1324
- to. The 'sessions' field shows how many HTTP client are currently being processed by
1325
- that application instance.
1663
+ Sessions:: Shows how many HTTP client are currently in the queue of that application
1664
+ Instance, waiting to be processed.
1665
+ Processed:: Indicates how many requests the instance has served until now. *Tip:* it's
1666
+ possible to limit this number with the <<PassengerMaxRequests,PassengerMaxRequests>>
1667
+ configuration directive.
1668
+ Uptime:: Shows for how long the application instance has been running.
1326
1669
 
1327
1670
  Since Phusion Passenger uses fair load balancing by default, the number of sessions for the
1328
1671
  application instances should be fairly close to each other. For example, this is fairly
1329
1672
  normal:
1330
1673
  --------------------------------
1331
- PID: 4281 Sessions: 2
1332
- PID: 4268 Sessions: 0
1333
- PID: 4265 Sessions: 1
1334
- PID: 4275 Sessions: 1
1674
+ PID: 4281 Sessions: 2 Processed: 7 Uptime: 5m 11s
1675
+ PID: 4268 Sessions: 0 Processed: 5 Uptime: 4m 52s
1676
+ PID: 4265 Sessions: 1 Processed: 6 Uptime: 5m 38s
1677
+ PID: 4275 Sessions: 1 Processed: 7 Uptime: 3m 14s
1335
1678
  --------------------------------
1336
1679
 
1337
1680
  But if you see a "spike", i.e. an application instance has an unusually high number of
1338
1681
  sessions compared to the others, then there might be a problem:
1339
1682
  --------------------------------
1340
- PID: 4281 Sessions: 2
1341
- PID: 17468 Sessions: 8 <---- "spike"
1342
- PID: 4265 Sessions: 1
1343
- PID: 4275 Sessions: 1
1683
+ PID: 4281 Sessions: 2 Processed: 7 Uptime: 5m 11s
1684
+ PID: 17468 Sessions: 8 <-+ Processed: 2 Uptime: 4m 47s
1685
+ PID: 4265 Sessions: 1 | Processed: 6 Uptime: 5m 38s
1686
+ PID: 4275 Sessions: 1 | Processed: 7 Uptime: 3m 14s
1687
+ |
1688
+ +---- "spike"
1344
1689
  --------------------------------
1345
1690
 
1346
1691
  Possible reasons why spikes can occur:
@@ -1376,7 +1721,7 @@ will restart killed application instances, as if nothing bad happened.
1376
1721
  [[user_switching]]
1377
1722
  === User switching (security) ===
1378
1723
 
1379
- There is a problem that plagues most PHP web host, namely the fact that all PHP
1724
+ There is a problem that plagues most PHP web hosts, namely the fact that all PHP
1380
1725
  applications are run in the same user context as the web server. So for
1381
1726
  example, Joe's PHP application will be able to read Jane's PHP application's
1382
1727
  passwords. This is obviously undesirable on many servers.
@@ -1434,30 +1779,37 @@ role :web, domain
1434
1779
  role :db, domain, :primary => true
1435
1780
 
1436
1781
  namespace :deploy do
1782
+ task :start, :roles => :app do
1783
+ run "touch #{current_release}/tmp/restart.txt"
1784
+ end
1785
+
1786
+ task :stop, :roles => :app do
1787
+ # Do nothing.
1788
+ end
1789
+
1437
1790
  desc "Restart Application"
1438
1791
  task :restart, :roles => :app do
1439
- run "touch #{current_path}/tmp/restart.txt"
1792
+ run "touch #{current_release}/tmp/restart.txt"
1440
1793
  end
1441
1794
  end
1442
1795
  --------------------------------------------------
1443
1796
 
1444
- [NOTE]
1445
- ==========================================================================
1446
- You may notice that for each deploy, a new spawner server is
1797
+ You may notice that after each deploy, a new spawner server is
1447
1798
  created (it'll show up in `passenger-memory-stats`). Indeed, Capistrano will deploy
1448
- to a path ending with '/current' (ie : '/var/www/yourapp/current'), so that you don't
1799
+ to a path ending with '/current' (ie : '/u/apps/yourapp/current'), so that you don't
1449
1800
  have to care about revisions in your virtual host configuration. This '/current' directory
1450
1801
  is a symlink to the current revision deployed ('/path_to_app/releases/date_of_the_release').
1451
- Therefore, when deploying a new version, the symlink will change, and Phusion Passenger
1452
- will think it's a new application, thereby creating a new spawner server:
1802
+ Phusion Passenger recognizes applications by their full canonical path, so after
1803
+ deploying a new version, Phusion Passenger will think that the new version is
1804
+ a totally different application, thereby creating a new spawner server:
1453
1805
 
1454
1806
  --------------------------------------------------
1455
- 1001 30291 [...] Passenger ApplicationSpawner: /var/www/my_app/releases/20080509104413
1456
- 1001 31371 [...] Passenger ApplicationSpawner: /var/www/my_app/releases/20080509104632
1807
+ 1001 30291 [...] Passenger ApplicationSpawner: /u/apps/my_app/releases/20080509104413
1808
+ 1001 31371 [...] Passenger ApplicationSpawner: /u/apps/my_app/releases/20080509104632
1457
1809
  --------------------------------------------------
1458
1810
 
1459
- Don't worry about this. The (old) spawner server will terminate itself after its default
1460
- timeout (10 minutes), so you will not run out of memory.
1811
+ Don't worry about this. The (old) spawner server will terminate itself after its
1812
+ timeout period (10 minutes by default), so you will not run out of memory.
1461
1813
 
1462
1814
  If you really want to release the spawner server's memory immediately, then you can add a command
1463
1815
  to your Capistrano script to terminate the Passenger spawn server after each deploy. That
@@ -1469,7 +1821,7 @@ kill $( passenger-memory-stats | grep 'Passenger spawn server' | awk '{ print $1
1469
1821
 
1470
1822
  Killing the spawn server is completely safe, because Phusion Passenger will restart the
1471
1823
  spawn server if it has been terminated.
1472
- ==========================================================================
1824
+
1473
1825
 
1474
1826
  === Moving Phusion Passenger to a different directory ===
1475
1827
 
@@ -1517,6 +1869,23 @@ Phusion Passenger does not provide upload progress support by itself. Please
1517
1869
  try drogus's link:http://github.com/drogus/apache-upload-progress-module/tree/master[
1518
1870
  Apache upload progress module] instead.
1519
1871
 
1872
+ === Making the application restart after each request ===
1873
+
1874
+ In some situations it might be desirable to restart the web application after
1875
+ each request, for example when developing a non-Rails application that doesn't
1876
+ support code reloading, or when developing a web framework.
1877
+
1878
+ To achieve this, simply create the file 'tmp/always_restart.txt' in your
1879
+ application's root folder. Unlike 'restart.txt', Phusion Passenger does not
1880
+ check for this file's timestamp: Phusion Passenger will always restart the
1881
+ application, as long as 'always_restart.txt' exists.
1882
+
1883
+ NOTE: If you're just developing a Rails application then you probably don't need
1884
+ this feature. If you set 'RailsEnv development' in your Apache configuration,
1885
+ then Rails will automatically reload your application code after each request.
1886
+ 'always_restart.txt' is only useful if you're working on Ruby on Rails itself,
1887
+ or when you're not developing a Rails application and your web framework
1888
+ does not support code reloading.
1520
1889
 
1521
1890
  == Appendix A: About this document ==
1522
1891
 
@@ -1532,3 +1901,372 @@ image:images/phusion_banner.png[link="http://www.phusion.nl/"]
1532
1901
 
1533
1902
  Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.
1534
1903
 
1904
+ == Appendix B: Terminology ==
1905
+
1906
+ [[application_root]]
1907
+ === Application root ===
1908
+ The root directory of an application that's served by Phusion Passenger.
1909
+
1910
+ In case of Ruby on Rails applications, this is the directory that contains
1911
+ 'Rakefile', 'app/', 'config/', 'public/', etc. In other words, the directory
1912
+ pointed to by `RAILS_ROOT`. For example, take the following directory structure:
1913
+
1914
+ -----------------------------------------
1915
+ /apps/foo/ <------ This is the Rails application's application root!
1916
+ |
1917
+ +- app/
1918
+ | |
1919
+ | +- controllers/
1920
+ | |
1921
+ | +- models/
1922
+ | |
1923
+ | +- views/
1924
+ |
1925
+ +- config/
1926
+ | |
1927
+ | +- environment.rb
1928
+ | |
1929
+ | +- ...
1930
+ |
1931
+ +- public/
1932
+ | |
1933
+ | +- ...
1934
+ |
1935
+ +- ...
1936
+ -----------------------------------------
1937
+
1938
+ In case of Rack applications, this is the directory that contains 'config.ru'.
1939
+ For example, take the following directory structure:
1940
+
1941
+ -----------------------------------------
1942
+ /apps/bar/ <----- This is the Rack application's application root!
1943
+ |
1944
+ +- public/
1945
+ | |
1946
+ | +- ...
1947
+ |
1948
+ +- config.ru
1949
+ |
1950
+ +- ...
1951
+ -----------------------------------------
1952
+
1953
+ In case of Python (WSGI) applications, this is the directory that contains
1954
+ 'passenger_wsgi.py'. For example, take the following directory structure:
1955
+
1956
+ -----------------------------------------
1957
+ /apps/baz/ <----- This is the WSGI application's application root!
1958
+ |
1959
+ +- public/
1960
+ | |
1961
+ | +- ...
1962
+ |
1963
+ +- passenger_wsgi.py
1964
+ |
1965
+ +- ...
1966
+ -----------------------------------------
1967
+
1968
+
1969
+ [[spawning_methods_explained]]
1970
+ == Appendix C: Spawning methods explained ==
1971
+
1972
+ At its core, Phusion Passenger is an HTTP proxy and process manager. It spawns
1973
+ Ruby on Rails/Rack/WSGI worker processes (which may also be referred to as
1974
+ 'backend processes'), and forwards incoming HTTP request to one of the worker
1975
+ processes.
1976
+
1977
+ While this may sound simple, there's not just one way to spawn worker processes.
1978
+ Let's go over the different spawning methods. For simplicity's sake, let's
1979
+ assume that we're only talking about Ruby on Rails applications.
1980
+
1981
+ === The most straightforward and traditional way: conservative spawning ===
1982
+
1983
+ Phusion Passenger could create a new Ruby process, which will then load the
1984
+ Rails application along with the entire Rails framework. This process will then
1985
+ enter an request handling main loop.
1986
+
1987
+ This is the most straightforward way to spawn worker processes. If you're
1988
+ familiar with the Mongrel application server, then this approach is exactly
1989
+ what mongrel_cluster performs: it creates N worker processes, each which loads
1990
+ a full copy of the Rails application and the Rails framework in memory. The Thin
1991
+ application server employs pretty much the same approach.
1992
+
1993
+ Note that Phusion Passenger's version of conservative spawning differs slightly
1994
+ from mongrel_cluster. Mongrel_cluster creates entirely new Ruby processes. In
1995
+ programmers jargon, mongrel_cluster creates new Ruby processes by forking the
1996
+ current process and exec()-ing a new Ruby interpreter. Phusion Passenger on the
1997
+ other hand creates processes that reuse the already loaded Ruby interpreter. In
1998
+ programmers jargon, Phusion Passenger calls fork(), but not exec().
1999
+
2000
+ === The smart spawning method ===
2001
+
2002
+ NOTE: Smart spawning is only available for Ruby on Rails applications, not for
2003
+ Rack applications or WSGI applications.
2004
+
2005
+ While conservative spawning works well, it's not as efficient as it could be
2006
+ because each worker process has its own private copy of the Rails application
2007
+ as well as the Rails framework. This wastes memory as well as startup time.
2008
+
2009
+ image:images/conservative_spawning.png[Worker processes and conservative spawning] +
2010
+ 'Figure: Worker processes and conservative spawning. Each worker process has its
2011
+ own private copy of the application code and Rails framework code.'
2012
+
2013
+ It is possible to make the different worker processes share the memory occupied
2014
+ by application and Rails framework code, by utilizing so-called
2015
+ copy-on-write semantics of the virtual memory system on modern operating
2016
+ systems. As a side effect, the startup time is also reduced. This is technique
2017
+ is exploited by Phusion Passenger's 'smart' and 'smart-lv2' spawn methods.
2018
+
2019
+ ==== How it works ====
2020
+
2021
+ When the 'smart-lv2' spawn method is being used, Phusion Passenger will first
2022
+ create a so-called 'ApplicationSpawner server' process. This process loads the
2023
+ entire Rails application along with the Rails framework, by loading
2024
+ 'environment.rb'. Then, whenever Phusion Passenger needs a new worker process,
2025
+ it will instruct the ApplicationSpawner server to do so. The ApplicationSpawner
2026
+ server will create a worker new process
2027
+ that reuses the already loaded Rails application/framework. Creating a worker
2028
+ process through an already running ApplicationSpawner server is very fast, about
2029
+ 10 times faster than loading the Rails application/framework from scratch. If
2030
+ the Ruby interpreter is copy-on-write friendly (that is, if you're running
2031
+ <<reducing_memory_usage,Ruby Enterprise Edition>>) then all created worker
2032
+ processes will share as much common
2033
+ memory as possible. That is, they will all share the same application and Rails
2034
+ framework code.
2035
+
2036
+ image:images/smart-lv2.png[] +
2037
+ 'Figure: Worker processes and the smart-lv2 spawn method. All worker processes,
2038
+ as well as the ApplicationSpawner, share the same application code and Rails
2039
+ framework code.'
2040
+
2041
+ The 'smart' spawn method goes even further, by caching the Rails framework in
2042
+ another process called the 'FrameworkSpawner server'. This process only loads
2043
+ the Rails framework, not the application. When a FrameworkSpawner server is
2044
+ instructed to create a new worker process, it will create a new
2045
+ ApplicationSpawner to which the instruction will be delegated. All those
2046
+ ApplicationSpawner servers, as well as all worker processes created by those
2047
+ ApplicationSpawner servers, will share the same Rails framework code.
2048
+
2049
+ The 'smart-lv2' method allows different worker processes that belong to the same
2050
+ application to share memory. The 'smart' method allows different worker
2051
+ processes - that happen to use the same Rails version - to share memory, even if
2052
+ they don't belong to the same application.
2053
+
2054
+ Notes:
2055
+
2056
+ - Vendored Rails frameworks cannot be shared by different applications, even if
2057
+ both vendored Rails frameworks are the same version. So for efficiency reasons
2058
+ we don't recommend vendoring Rails.
2059
+ - ApplicationSpawner and FrameworkSpawner servers have an idle timeout just
2060
+ like worker processes. If an ApplicationSpawner/FrameworkSpawner server hasn't
2061
+ been instructed to do anything for a while, it will be shutdown in order to
2062
+ conserve memory. This idle timeout is configurable.
2063
+
2064
+ ==== Summary of benefits ====
2065
+
2066
+ Suppose that Phusion Passenger needs a new worker process for an application
2067
+ that uses Rails 2.2.1.
2068
+
2069
+ - If the 'smart-lv2' spawning method is used, and an ApplicationSpawner server
2070
+ for this application is already running, then worker process creation time is
2071
+ about 10 times faster than conservative spawning. This worker process will also
2072
+ share application and Rails framework code memory with the ApplicationSpawner
2073
+ server and the worker processes that had been spawned by this ApplicationSpawner
2074
+ server.
2075
+ - If the 'smart' spawning method is used, and a FrameworkSpawner server for
2076
+ Rails 2.2.1 is already running, but no ApplicationSpawner server for this
2077
+ application is running, then worker process creation time is about 2 times
2078
+ faster than conservative spawning. If there is an ApplicationSpawner server
2079
+ for this application running, then worker process creation time is about 10
2080
+ times faster. This worker process will also share application and Rails
2081
+ framework code memory with the ApplicationSpawner and FrameworkSpawner
2082
+ servers.
2083
+
2084
+ You could compare ApplicationSpawner and FrameworkSpawner servers with stem
2085
+ cells, that have the ability to quickly change into more specific cells (worker
2086
+ process).
2087
+
2088
+ In practice, the smart spawning methods could mean a memory saving of about 33%,
2089
+ assuming that your Ruby interpreter is <<reducing_memory_usage,copy-on-write friendly>>.
2090
+
2091
+ Of course, smart spawning is not without gotchas. But if you understand the
2092
+ gotchas you can easily reap the benefits of smart spawning.
2093
+
2094
+ === Smart spawning gotcha #1: unintential file descriptor sharing ===
2095
+
2096
+ Because worker processes are created by forking from an ApplicationSpawner
2097
+ server, it will share all file descriptors that are opened by the
2098
+ ApplicationSpawner server. (This is part of the semantics of the Unix
2099
+ 'fork()' system call. You might want to Google it if you're not familiar with
2100
+ it.) A file descriptor is a handle which can be an opened file, an opened socket
2101
+ connection, a pipe, etc. If different worker processes write to such a file
2102
+ descriptor at the same time, then their write calls will be interleaved, which
2103
+ may potentially cause problems.
2104
+
2105
+ The problem commonly involves socket connections that are unintentially being
2106
+ shared. You can fix it by closing and reestablishing the connection when Phusion
2107
+ Passenger is creating a new worker process. Phusion Passenger provides the API
2108
+ call `PhusionPassenger.on_event(:starting_worker_process)` to do so. So you
2109
+ could insert the following code in your 'environment.rb':
2110
+
2111
+ [source, ruby]
2112
+ -----------------------------------------
2113
+ if defined?(PhusionPassenger)
2114
+ PhusionPassenger.on_event(:starting_worker_process) do |forked|
2115
+ if forked
2116
+ # We're in smart spawning mode.
2117
+ ... code to reestablish socket connections here ...
2118
+ else
2119
+ # We're in conservative spawning mode. We don't need to do anything.
2120
+ end
2121
+ end
2122
+ end
2123
+ -----------------------------------------
2124
+
2125
+ Note that Phusion Passenger automatically reestablishes the connection to the
2126
+ database upon creating a new worker process, which is why you normally do not
2127
+ encounter any database issues when using smart spawning mode.
2128
+
2129
+ ==== Example 1: Memcached connection sharing (harmful) ====
2130
+
2131
+ Suppose we have a Rails application that connects to a Memcached server in
2132
+ 'environment.rb'. This causes the ApplicationSpawner to have a socket connection
2133
+ (file descriptor) to the Memcached server, as shown in the following figure:
2134
+
2135
+ +--------------------+
2136
+ | ApplicationSpawner |-----------[Memcached server]
2137
+ +--------------------+
2138
+
2139
+ Phusion Passenger then proceeds with creating a new Rails worker process, which
2140
+ is to process incoming HTTP requests. The result will look like this:
2141
+
2142
+ +--------------------+
2143
+ | ApplicationSpawner |------+----[Memcached server]
2144
+ +--------------------+ |
2145
+ |
2146
+ +--------------------+ |
2147
+ | Worker process 1 |-----/
2148
+ +--------------------+
2149
+
2150
+ Since a 'fork()' makes a (virtual) complete copy of a process, all its file
2151
+ descriptors will be copied as well. What we see here is that ApplicationSpawner
2152
+ and Worker process 1 both share the same connection to Memcached.
2153
+
2154
+ Now supposed that your site gets Slashdotted and Phusion Passenger needs to
2155
+ spawn another worker process. It does so by forking ApplicationSpawner. The
2156
+ result is now as follows:
2157
+
2158
+ +--------------------+
2159
+ | ApplicationSpawner |------+----[Memcached server]
2160
+ +--------------------+ |
2161
+ |
2162
+ +--------------------+ |
2163
+ | Worker process 1 |-----/|
2164
+ +--------------------+ |
2165
+ |
2166
+ +--------------------+ |
2167
+ | Worker process 2 |-----/
2168
+ +--------------------+
2169
+
2170
+ As you can see, Worker process 1 and Worker process 2 have the same Memcache
2171
+ connection.
2172
+
2173
+ Suppose that users Joe and Jane visit your website at the same time. Joe's
2174
+ request is handled by Worker process 1, and Jane's request is handled by Worker
2175
+ process 2. Both worker processes want to fetch something from Memcached. Suppose
2176
+ that in order to do that, both handlers need to send a "FETCH" command to Memcached.
2177
+
2178
+ But suppose that, after worker process 1 having only sent "FE", a context switch
2179
+ occurs, and worker process 2 starts sending a "FETCH" command to Memcached as
2180
+ well. If worker process 2 succeeds in sending only one bye, 'F', then Memcached
2181
+ will receive a command which begins with "FEF", a command that it does not
2182
+ recognize. In other words: the data from both handlers get interleaved. And thus
2183
+ Memcached is forced to handle this as an error.
2184
+
2185
+ This problem can be solved by reestablishing the connection to Memcached after forking:
2186
+
2187
+ +--------------------+
2188
+ | ApplicationSpawner |------+----[Memcached server]
2189
+ +--------------------+ | |
2190
+ | |
2191
+ +--------------------+ | |
2192
+ | Worker process 1 |-----/| |
2193
+ +--------------------+ | | <--- created this
2194
+ X | new
2195
+ | connection
2196
+ X <-- closed this |
2197
+ +--------------------+ | old |
2198
+ | Worker process 2 |-----/ connection |
2199
+ +--------------------+ |
2200
+ | |
2201
+ +-------------------------------------+
2202
+
2203
+ Worker process 2 now has its own, separate communication channel with Memcached.
2204
+ The code in 'environment.rb' looks like this:
2205
+
2206
+ [source, ruby]
2207
+ -----------------------------------------
2208
+ if defined?(PhusionPassenger)
2209
+ PhusionPassenger.on_event(:starting_worker_process) do |forked|
2210
+ if forked
2211
+ # We're in smart spawning mode.
2212
+ reestablish_connection_to_memcached
2213
+ else
2214
+ # We're in conservative spawning mode. We don't need to do anything.
2215
+ end
2216
+ end
2217
+ end
2218
+ -----------------------------------------
2219
+
2220
+ ==== Example 2: Log file sharing (not harmful) ====
2221
+
2222
+ There are also cases in which unintential file descriptor sharing is not harmful.
2223
+ One such case is log file file descriptor sharing. Even if two processes write
2224
+ to the log file at the same time, the worst thing that can happen is that the
2225
+ data in the log file is interleaved.
2226
+
2227
+ To guarantee that the data written to the log file is never interleaved, you
2228
+ must synchronize write access via an inter-process synchronization mechanism,
2229
+ such as file locks. Reopening the log file, like you would have done in the
2230
+ Memcached example, doesn't help.
2231
+
2232
+ === Smart spawning gotcha #2: the need to revive threads ===
2233
+
2234
+ Another part of the 'fork()' system call's semantics is the fact that threads
2235
+ disappear after a fork call. So if you've created any threads in environment.rb,
2236
+ then those threads will no longer be running in newly created worker process.
2237
+ You need to revive them when a new worker process is created. Use the
2238
+ `:starting_worker_process` event that Phusion Passenger provides, like this:
2239
+
2240
+ [source, ruby]
2241
+ -----------------------------------------
2242
+ if defined?(PhusionPassenger)
2243
+ PhusionPassenger.on_event(:starting_worker_process) do |forked|
2244
+ if forked
2245
+ # We're in smart spawning mode.
2246
+ ... code to revive threads here ...
2247
+ else
2248
+ # We're in conservative spawning mode. We don't need to do anything.
2249
+ end
2250
+ end
2251
+ end
2252
+ -----------------------------------------
2253
+
2254
+ === Smart spawning gotcha #3: code load order ===
2255
+
2256
+ This gotcha is only applicable to the 'smart' spawn method, not the 'smart-lv2'
2257
+ spawn method.
2258
+
2259
+ If your application expects the Rails framework to be not loaded during the
2260
+ beginning of 'environment.rb', then it can cause problems when an
2261
+ ApplicationSpawner is created from a FrameworkSpawner, which already has the
2262
+ Rails framework loaded. The most common case is when applications try to patch
2263
+ Rails by dropping a modified file that has the same name as Rails's own file,
2264
+ in a path that comes earlier in the Ruby search path.
2265
+
2266
+ For example, suppose that we have an application which has a patched version
2267
+ of 'active_record/base.rb' located in 'RAILS_ROOT/lib/patches', and
2268
+ 'RAILS_ROOT/lib/patches' comes first in the Ruby load path. When conservative
2269
+ spawning is used, the patched version of 'base.rb' is properly loaded. When
2270
+ 'smart' (not 'smart-lv2') spawning is used, the original 'base.rb' is used
2271
+ because it was already loaded, so a subsequent `require "active_record/base"`
2272
+ has no effect.