passenger 2.2.2 → 2.2.3

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 (254) hide show
  1. data/DEVELOPERS.TXT +13 -3
  2. data/Rakefile +42 -33
  3. data/bin/passenger-install-apache2-module +1 -2
  4. data/bin/passenger-install-nginx-module +7 -19
  5. data/bin/passenger-status +64 -15
  6. data/bin/passenger-stress-test +2 -2
  7. data/doc/ApplicationPool algorithm.txt +26 -22
  8. data/doc/Users guide Apache.html +374 -149
  9. data/doc/Users guide Apache.txt +318 -51
  10. data/doc/Users guide Nginx.html +13 -13
  11. data/doc/Users guide Nginx.txt +7 -2
  12. data/doc/cxxapi/Bucket_8h-source.html +62 -25
  13. data/doc/cxxapi/Configuration_8h-source.html +343 -326
  14. data/doc/cxxapi/DirectoryMapper_8h-source.html +12 -12
  15. data/doc/cxxapi/Hooks_8h-source.html +1 -1
  16. data/doc/cxxapi/annotated.html +1 -1
  17. data/doc/cxxapi/classHooks-members.html +1 -1
  18. data/doc/cxxapi/classHooks.html +1 -1
  19. data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +2 -2
  20. data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +9 -9
  21. data/doc/cxxapi/classes.html +1 -1
  22. data/doc/cxxapi/definitions_8h-source.html +1 -1
  23. data/doc/cxxapi/files.html +1 -1
  24. data/doc/cxxapi/functions.html +2 -2
  25. data/doc/cxxapi/functions_func.html +2 -2
  26. data/doc/cxxapi/graph_legend.html +1 -1
  27. data/doc/cxxapi/group__Configuration.html +1 -1
  28. data/doc/cxxapi/group__Core.html +1 -1
  29. data/doc/cxxapi/group__Hooks.html +1 -1
  30. data/doc/cxxapi/group__Support.html +1 -1
  31. data/doc/cxxapi/main.html +1 -1
  32. data/doc/cxxapi/modules.html +1 -1
  33. data/doc/rdoc/classes/ConditionVariable.html +194 -0
  34. data/doc/rdoc/classes/Exception.html +120 -0
  35. data/doc/rdoc/classes/GC.html +113 -0
  36. data/doc/rdoc/classes/IO.html +169 -0
  37. data/doc/rdoc/classes/PhusionPassenger.html +238 -0
  38. data/doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html +153 -0
  39. data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +517 -0
  40. data/doc/rdoc/classes/PhusionPassenger/AbstractServer.html +719 -0
  41. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerAlreadyStarted.html +97 -0
  42. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerError.html +96 -0
  43. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerNotStarted.html +97 -0
  44. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/UnknownMessage.html +96 -0
  45. data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +598 -0
  46. data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +140 -0
  47. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess.html +317 -0
  48. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess/Instance.html +138 -0
  49. data/doc/rdoc/classes/PhusionPassenger/AppInitError.html +154 -0
  50. data/doc/rdoc/classes/PhusionPassenger/Application.html +283 -0
  51. data/doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html +172 -0
  52. data/doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html +145 -0
  53. data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +175 -0
  54. data/doc/rdoc/classes/PhusionPassenger/InitializationError.html +141 -0
  55. data/doc/rdoc/classes/PhusionPassenger/InvalidPath.html +92 -0
  56. data/doc/rdoc/classes/PhusionPassenger/MessageChannel.html +489 -0
  57. data/doc/rdoc/classes/PhusionPassenger/NativeSupport.html +350 -0
  58. data/doc/rdoc/classes/PhusionPassenger/Rack.html +91 -0
  59. data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +188 -0
  60. data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +194 -0
  61. data/doc/rdoc/classes/PhusionPassenger/Railz.html +95 -0
  62. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +442 -0
  63. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner/Error.html +98 -0
  64. data/doc/rdoc/classes/PhusionPassenger/Railz/CGIFixed.html +200 -0
  65. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +436 -0
  66. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner/Error.html +98 -0
  67. data/doc/rdoc/classes/PhusionPassenger/Railz/RequestHandler.html +155 -0
  68. data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +402 -0
  69. data/doc/rdoc/classes/PhusionPassenger/UnknownError.html +125 -0
  70. data/doc/rdoc/classes/PhusionPassenger/Utils.html +805 -0
  71. data/doc/rdoc/classes/PhusionPassenger/VersionNotFound.html +140 -0
  72. data/doc/rdoc/classes/PhusionPassenger/WSGI.html +89 -0
  73. data/doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html +188 -0
  74. data/doc/rdoc/classes/PlatformInfo.html +831 -0
  75. data/doc/rdoc/classes/RakeExtensions.html +197 -0
  76. data/doc/rdoc/classes/Signal.html +131 -0
  77. data/doc/rdoc/created.rid +1 -0
  78. data/doc/rdoc/files/DEVELOPERS_TXT.html +255 -0
  79. data/doc/rdoc/files/README.html +157 -0
  80. data/doc/rdoc/files/ext/phusion_passenger/native_support_c.html +92 -0
  81. data/doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html +129 -0
  82. data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +131 -0
  83. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +126 -0
  84. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +130 -0
  85. data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +130 -0
  86. data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +122 -0
  87. data/doc/rdoc/files/lib/phusion_passenger/application_rb.html +127 -0
  88. data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +126 -0
  89. data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +122 -0
  90. data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +134 -0
  91. data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +122 -0
  92. data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +122 -0
  93. data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +126 -0
  94. data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +122 -0
  95. data/doc/rdoc/files/lib/phusion_passenger/packaging_rb.html +122 -0
  96. data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +127 -0
  97. data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +133 -0
  98. data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +127 -0
  99. data/doc/rdoc/files/lib/phusion_passenger/railz/application_spawner_rb.html +143 -0
  100. data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +126 -0
  101. data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +145 -0
  102. data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +127 -0
  103. data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +122 -0
  104. data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +161 -0
  105. data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +175 -0
  106. data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +129 -0
  107. data/doc/rdoc/files/misc/rake/extensions_rb.html +130 -0
  108. data/doc/rdoc/fr_class_index.html +90 -0
  109. data/doc/rdoc/fr_file_index.html +76 -0
  110. data/doc/rdoc/fr_method_index.html +200 -0
  111. data/doc/rdoc/index.html +26 -0
  112. data/doc/rdoc/rdoc-style.css +187 -0
  113. data/doc/users_guide_snippets/rackup_specifications.txt +2 -8
  114. data/ext/apache2/Bucket.cpp +71 -38
  115. data/ext/apache2/Bucket.h +53 -16
  116. data/ext/apache2/Configuration.cpp +15 -0
  117. data/ext/apache2/Configuration.h +19 -2
  118. data/ext/apache2/DirectoryMapper.h +10 -10
  119. data/ext/apache2/Hooks.cpp +334 -74
  120. data/ext/boost/mpl/apply.hpp +5 -1
  121. data/ext/boost/mpl/apply_wrap.hpp +5 -2
  122. data/ext/boost/mpl/aux_/full_lambda.hpp +5 -1
  123. data/ext/boost/mpl/bind.hpp +5 -1
  124. data/ext/common/Application.h +11 -31
  125. data/ext/common/ApplicationPool.h +2 -1
  126. data/ext/common/ApplicationPoolServer.h +61 -20
  127. data/ext/common/ApplicationPoolServerExecutable.cpp +132 -4
  128. data/ext/common/ApplicationPoolStatusReporter.h +189 -65
  129. data/ext/common/Base64.cpp +143 -0
  130. data/ext/common/Base64.h +57 -0
  131. data/ext/common/CachedFileStat.cpp +25 -82
  132. data/ext/common/CachedFileStat.h +11 -125
  133. data/ext/common/CachedFileStat.hpp +243 -0
  134. data/ext/common/Exceptions.h +13 -0
  135. data/ext/common/FileChangeChecker.h +209 -0
  136. data/ext/common/Logging.h +3 -2
  137. data/ext/common/MessageChannel.h +10 -10
  138. data/ext/common/PoolOptions.h +72 -5
  139. data/ext/common/SpawnManager.h +11 -8
  140. data/ext/common/StandardApplicationPool.h +38 -39
  141. data/ext/common/StaticString.h +1 -0
  142. data/ext/common/StringListCreator.h +83 -0
  143. data/ext/common/SystemTime.h +3 -2
  144. data/ext/common/Timer.h +88 -0
  145. data/ext/common/Utils.cpp +161 -42
  146. data/ext/common/Utils.h +62 -31
  147. data/ext/common/Version.h +1 -1
  148. data/ext/nginx/Configuration.c +0 -4
  149. data/ext/nginx/ContentHandler.c +8 -6
  150. data/ext/nginx/HelperServer.cpp +45 -55
  151. data/ext/nginx/HttpStatusExtractor.h +4 -0
  152. data/ext/nginx/StaticContentHandler.c +25 -5
  153. data/ext/nginx/config +3 -0
  154. data/ext/nginx/ngx_http_passenger_module.c +72 -17
  155. data/ext/nginx/ngx_http_passenger_module.h +2 -2
  156. data/lib/phusion_passenger/abstract_request_handler.rb +15 -7
  157. data/lib/phusion_passenger/abstract_server.rb +16 -2
  158. data/lib/phusion_passenger/admin_tools/control_process.rb +36 -25
  159. data/lib/phusion_passenger/constants.rb +1 -1
  160. data/lib/phusion_passenger/dependencies.rb +10 -0
  161. data/lib/phusion_passenger/platform_info.rb +1 -1
  162. data/lib/phusion_passenger/rack/application_spawner.rb +21 -2
  163. data/lib/phusion_passenger/rack/request_handler.rb +10 -0
  164. data/lib/phusion_passenger/railz/application_spawner.rb +38 -2
  165. data/lib/phusion_passenger/railz/framework_spawner.rb +26 -28
  166. data/lib/phusion_passenger/railz/request_handler.rb +5 -1
  167. data/lib/phusion_passenger/spawn_manager.rb +6 -2
  168. data/lib/phusion_passenger/utils.rb +79 -27
  169. data/misc/rake/cplusplus.rb +5 -5
  170. data/test/ApplicationPoolServerTest.cpp +42 -0
  171. data/test/ApplicationPoolTest.cpp +255 -267
  172. data/test/Base64Test.cpp +48 -0
  173. data/test/CachedFileStatTest.cpp +243 -103
  174. data/test/FileChangeCheckerTest.cpp +331 -0
  175. data/test/PoolOptionsTest.cpp +80 -0
  176. data/test/UtilsTest.cpp +5 -17
  177. data/test/integration_tests/apache2_tests.rb +15 -4
  178. data/test/integration_tests/mycook_spec.rb +3 -4
  179. data/test/oxt/syscall_interruption_test.cpp +2 -14
  180. data/test/ruby/abstract_server_collection_spec.rb +1 -1
  181. data/test/ruby/abstract_server_spec.rb +35 -1
  182. data/test/ruby/rack/application_spawner_spec.rb +23 -6
  183. data/test/ruby/rails/application_spawner_spec.rb +6 -6
  184. data/test/ruby/rails/framework_spawner_spec.rb +6 -5
  185. data/test/ruby/rails/minimal_spawner_spec.rb +19 -0
  186. data/test/ruby/rails/spawner_error_handling_spec.rb +62 -7
  187. data/test/ruby/spawn_manager_spec.rb +10 -7
  188. data/test/ruby/spawn_server_spec.rb +1 -1
  189. data/test/ruby/utils_spec.rb +193 -20
  190. data/test/ruby/wsgi/application_spawner_spec.rb +3 -1
  191. data/test/stub/apache2/httpd.conf.erb +3 -0
  192. data/test/stub/rack/config.ru +1 -1
  193. data/test/stub/rails_apps/mycook/app/controllers/welcome_controller.rb +8 -0
  194. data/test/support/Support.cpp +84 -0
  195. data/test/support/Support.h +66 -8
  196. data/test/support/config.rb +14 -2
  197. data/test/support/test_helper.rb +5 -0
  198. data/vendor/rack-1.0.0-git/lib/rack/auth/openid.rb +123 -116
  199. data/vendor/rack-1.0.0-git/lib/rack/cascade.rb +17 -12
  200. data/vendor/rack-1.0.0-git/lib/rack/commonlogger.rb +34 -43
  201. data/vendor/rack-1.0.0-git/lib/rack/handler/cgi.rb +1 -1
  202. data/vendor/rack-1.0.0-git/lib/rack/handler/fastcgi.rb +1 -1
  203. data/vendor/rack-1.0.0-git/lib/rack/handler/lsws.rb +1 -1
  204. data/vendor/rack-1.0.0-git/lib/rack/handler/mongrel.rb +1 -1
  205. data/vendor/rack-1.0.0-git/lib/rack/handler/scgi.rb +1 -1
  206. data/vendor/rack-1.0.0-git/lib/rack/handler/webrick.rb +1 -1
  207. data/vendor/rack-1.0.0-git/lib/rack/mock.rb +4 -17
  208. data/vendor/rack-1.0.0-git/lib/rack/request.rb +3 -9
  209. data/vendor/rack-1.0.0-git/lib/rack/rewindable_input.rb +2 -0
  210. data/vendor/rack-1.0.0-git/lib/rack/utils.rb +38 -12
  211. metadata +231 -186
  212. data/ext/common/FileChecker.h +0 -112
  213. data/test/FileCheckerTest.cpp +0 -79
  214. data/test/stub/minimal-railsapp/README +0 -3
  215. data/test/stub/minimal-railsapp/config/application.rb +0 -0
  216. data/test/stub/minimal-railsapp/config/environment.rb +0 -3
  217. data/test/stub/minimal-railsapp/vendor/rails/actionmailer/lib/action_mailer.rb +0 -0
  218. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_controller.rb +0 -10
  219. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_pack.rb +0 -0
  220. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_view.rb +0 -0
  221. data/test/stub/minimal-railsapp/vendor/rails/activerecord/lib/active_record.rb +0 -7
  222. data/test/stub/minimal-railsapp/vendor/rails/activeresource/lib/active_resource.rb +0 -0
  223. data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support.rb +0 -17
  224. data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support/whiny_nil.rb +0 -0
  225. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/dispatcher.rb +0 -0
  226. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/initializer.rb +0 -8
  227. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/ruby_version_check.rb +0 -1
  228. data/test/stub/railsapp/app/controllers/application.rb +0 -12
  229. data/test/stub/railsapp/app/controllers/bar_controller.rb +0 -5
  230. data/test/stub/railsapp/app/controllers/bar_controller_1.txt +0 -5
  231. data/test/stub/railsapp/app/controllers/bar_controller_2.txt +0 -5
  232. data/test/stub/railsapp/app/controllers/foo_controller.rb +0 -9
  233. data/test/stub/railsapp/app/helpers/application_helper.rb +0 -3
  234. data/test/stub/railsapp/config/boot.rb +0 -108
  235. data/test/stub/railsapp/config/database.yml +0 -19
  236. data/test/stub/railsapp/config/environment.rb +0 -59
  237. data/test/stub/railsapp/config/environments/development.rb +0 -18
  238. data/test/stub/railsapp/config/environments/production.rb +0 -19
  239. data/test/stub/railsapp/config/initializers/inflections.rb +0 -10
  240. data/test/stub/railsapp/config/initializers/mime_types.rb +0 -5
  241. data/test/stub/railsapp/config/routes.rb +0 -35
  242. data/test/stub/railsapp/public/useless.txt +0 -1
  243. data/test/stub/railsapp2/app/controllers/application.rb +0 -12
  244. data/test/stub/railsapp2/app/controllers/foo_controller.rb +0 -5
  245. data/test/stub/railsapp2/app/helpers/application_helper.rb +0 -3
  246. data/test/stub/railsapp2/config/boot.rb +0 -108
  247. data/test/stub/railsapp2/config/database.yml +0 -19
  248. data/test/stub/railsapp2/config/environment.rb +0 -59
  249. data/test/stub/railsapp2/config/environments/development.rb +0 -18
  250. data/test/stub/railsapp2/config/environments/production.rb +0 -19
  251. data/test/stub/railsapp2/config/initializers/inflections.rb +0 -10
  252. data/test/stub/railsapp2/config/initializers/mime_types.rb +0 -5
  253. data/test/stub/railsapp2/config/routes.rb +0 -35
  254. data/test/stub/railsapp2/public/useless.txt +0 -1
@@ -0,0 +1,194 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+ <html>
6
+ <head>
7
+ <title>Class: PhusionPassenger::Rack::RequestHandler</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
10
+
11
+ <script language="JavaScript" type="text/javascript">
12
+ // <![CDATA[
13
+
14
+ function toggleSource( id )
15
+ {
16
+ var elem
17
+ var link
18
+
19
+ if( document.getElementById )
20
+ {
21
+ elem = document.getElementById( id )
22
+ link = document.getElementById( "l_" + id )
23
+ }
24
+ else if ( document.all )
25
+ {
26
+ elem = eval( "document.all." + id )
27
+ link = eval( "document.all.l_" + id )
28
+ }
29
+ else
30
+ return false;
31
+
32
+ if( elem.style.display == "block" )
33
+ {
34
+ elem.style.display = "none"
35
+ link.innerHTML = "show source"
36
+ }
37
+ else
38
+ {
39
+ elem.style.display = "block"
40
+ link.innerHTML = "hide source"
41
+ }
42
+ }
43
+
44
+ function openCode( url )
45
+ {
46
+ window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
47
+ }
48
+ // ]]>
49
+ </script>
50
+ </head>
51
+
52
+ <body>
53
+ <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
54
+ <td class="file-title"><span class="file-title-prefix">Class</span><br />PhusionPassenger::Rack::RequestHandler</td>
55
+ <td align="right">
56
+ <table cellspacing="0" cellpadding="2">
57
+ <tr valign="top">
58
+ <td>In:</td>
59
+ <td>
60
+ <a href="../../../files/lib/phusion_passenger/rack/request_handler_rb.html">lib/phusion_passenger/rack/request_handler.rb</a>
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>Parent:</td>
65
+ <td>
66
+ AbstractRequestHandler
67
+ </td>
68
+ </tr>
69
+ </table>
70
+ </td>
71
+ </tr>
72
+ </table>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+ <div id="content">
77
+
78
+ <div class="description"><p>
79
+ A request handler for <a href="../Rack.html">Rack</a> applications.
80
+ </p>
81
+ </div>
82
+
83
+
84
+
85
+ <div class="sectiontitle">Methods</div>
86
+ <ul>
87
+ <li><a href="#M000056">new</a></li>
88
+ <li><a href="#M000057">process_request</a></li>
89
+ </ul>
90
+
91
+
92
+
93
+
94
+
95
+
96
+ <div class="sectiontitle">Public Class methods</div>
97
+ <div class="method">
98
+ <div class="title">
99
+ <a name="M000056"></a><b>new</b>(owner_pipe, app, options = {})
100
+ </div>
101
+ <div class="description">
102
+ <p>
103
+ <tt>app</tt> is the <a href="../Rack.html">Rack</a> application object.
104
+ </p>
105
+ </div>
106
+ <div class="sourcecode">
107
+ <p class="source-link">[ <a href="javascript:toggleSource('M000056_source')" id="l_M000056_source">show source</a> ]</p>
108
+ <div id="M000056_source" class="dyn-source">
109
+ <pre>
110
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/rack/request_handler.rb, line 60</span>
111
+ 60: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">owner_pipe</span>, <span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span> = {})
112
+ 61: <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">owner_pipe</span>, <span class="ruby-identifier">options</span>)
113
+ 62: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
114
+ 63: <span class="ruby-keyword kw">end</span>
115
+ </pre>
116
+ </div>
117
+ </div>
118
+ </div>
119
+ <div class="sectiontitle">Protected Instance methods</div>
120
+ <div class="method">
121
+ <div class="title">
122
+ <a name="M000057"></a><b>process_request</b>(env, input, output)
123
+ </div>
124
+ <div class="description">
125
+ <p>
126
+ Overrided method.
127
+ </p>
128
+ </div>
129
+ <div class="sourcecode">
130
+ <p class="source-link">[ <a href="javascript:toggleSource('M000057_source')" id="l_M000057_source">show source</a> ]</p>
131
+ <div id="M000057_source" class="dyn-source">
132
+ <pre>
133
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/rack/request_handler.rb, line 67</span>
134
+ 67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_request</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">input</span>, <span class="ruby-identifier">output</span>)
135
+ 68: <span class="ruby-identifier">rewindable_input</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">RewindableInput</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">input</span>)
136
+ 69: <span class="ruby-keyword kw">begin</span>
137
+ 70: <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_VERSION</span>] = <span class="ruby-constant">RACK_VERSION_VALUE</span>
138
+ 71: <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_INPUT</span>] = <span class="ruby-identifier">rewindable_input</span>
139
+ 72: <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_ERRORS</span>] = <span class="ruby-constant">STDERR</span>
140
+ 73: <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_MULTITHREAD</span>] = <span class="ruby-keyword kw">false</span>
141
+ 74: <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_MULTIPROCESS</span>] = <span class="ruby-keyword kw">true</span>
142
+ 75: <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_RUN_ONCE</span>] = <span class="ruby-keyword kw">false</span>
143
+ 76: <span class="ruby-identifier">env</span>[<span class="ruby-constant">QUERY_STRING</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
144
+ 77: <span class="ruby-identifier">env</span>[<span class="ruby-constant">PATH_INFO</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">REQUEST_URI</span>].<span class="ruby-identifier">split</span>(<span class="ruby-constant">QUESTION_MARK</span>, <span class="ruby-value">2</span>).<span class="ruby-identifier">first</span>
145
+ 78: <span class="ruby-identifier">env</span>[<span class="ruby-constant">PATH_INFO</span>].<span class="ruby-identifier">sub!</span>(<span class="ruby-node">/^#{Regexp.escape(env[SCRIPT_NAME])}/</span>, <span class="ruby-value str">&quot;&quot;</span>)
146
+ 79: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">HTTP_CONTENT_LENGTH</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">CONTENT_LENGTH</span>]
147
+ 80: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-constant">HTTP_CONTENT_LENGTH</span>)
148
+ 81: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">HTTP_CONTENT_LENGTH</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">env</span>[<span class="ruby-constant">CONTENT_LENGTH</span>]
149
+ 82: <span class="ruby-identifier">env</span>[<span class="ruby-constant">CONTENT_LENGTH</span>] = <span class="ruby-identifier">env</span>[<span class="ruby-constant">HTTP_CONTENT_LENGTH</span>]
150
+ 83: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-constant">HTTP_CONTENT_LENGTH</span>)
151
+ 84: <span class="ruby-keyword kw">end</span>
152
+ 85: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">HTTPS</span>] <span class="ruby-operator">==</span> <span class="ruby-constant">YES</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">HTTPS</span>] <span class="ruby-operator">==</span> <span class="ruby-constant">ON</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">HTTPS</span>] <span class="ruby-operator">==</span> <span class="ruby-constant">ONE</span>
153
+ 86: <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_URL_SCHEME</span>] = <span class="ruby-constant">HTTPS_DOWNCASE</span>
154
+ 87: <span class="ruby-keyword kw">else</span>
155
+ 88: <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_URL_SCHEME</span>] = <span class="ruby-constant">HTTP</span>
156
+ 89: <span class="ruby-keyword kw">end</span>
157
+ 90:
158
+ 91: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
159
+ 92: <span class="ruby-keyword kw">begin</span>
160
+ 93: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;Status: #{status.to_i}#{CRLF}&quot;</span>)
161
+ 94: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;X-Powered-By: #{PASSENGER_HEADER}#{CRLF}&quot;</span>)
162
+ 95: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">values</span><span class="ruby-operator">|</span>
163
+ 96: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">values</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
164
+ 97: <span class="ruby-identifier">values</span> = <span class="ruby-identifier">values</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
165
+ 98: <span class="ruby-keyword kw">end</span>
166
+ 99: <span class="ruby-identifier">values</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
167
+ 100: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;#{key}: #{value}#{CRLF}&quot;</span>)
168
+ 101: <span class="ruby-keyword kw">end</span>
169
+ 102: <span class="ruby-keyword kw">end</span>
170
+ 103: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">CRLF</span>)
171
+ 104: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
172
+ 105: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">body</span>)
173
+ 106: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">body</span>
174
+ 107: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
175
+ 108: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">s</span>)
176
+ 109: <span class="ruby-keyword kw">end</span>
177
+ 110: <span class="ruby-keyword kw">end</span>
178
+ 111: <span class="ruby-keyword kw">ensure</span>
179
+ 112: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:close</span>)
180
+ 113: <span class="ruby-keyword kw">end</span>
181
+ 114: <span class="ruby-keyword kw">ensure</span>
182
+ 115: <span class="ruby-identifier">rewindable_input</span>.<span class="ruby-identifier">close</span>
183
+ 116: <span class="ruby-keyword kw">end</span>
184
+ 117: <span class="ruby-keyword kw">end</span>
185
+ </pre>
186
+ </div>
187
+ </div>
188
+ </div>
189
+ </div>
190
+
191
+ </div>
192
+
193
+ </body>
194
+ </html>
@@ -0,0 +1,95 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+ <html>
6
+ <head>
7
+ <title>Module: PhusionPassenger::Railz</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
10
+
11
+ <script language="JavaScript" type="text/javascript">
12
+ // <![CDATA[
13
+
14
+ function toggleSource( id )
15
+ {
16
+ var elem
17
+ var link
18
+
19
+ if( document.getElementById )
20
+ {
21
+ elem = document.getElementById( id )
22
+ link = document.getElementById( "l_" + id )
23
+ }
24
+ else if ( document.all )
25
+ {
26
+ elem = eval( "document.all." + id )
27
+ link = eval( "document.all.l_" + id )
28
+ }
29
+ else
30
+ return false;
31
+
32
+ if( elem.style.display == "block" )
33
+ {
34
+ elem.style.display = "none"
35
+ link.innerHTML = "show source"
36
+ }
37
+ else
38
+ {
39
+ elem.style.display = "block"
40
+ link.innerHTML = "hide source"
41
+ }
42
+ }
43
+
44
+ function openCode( url )
45
+ {
46
+ window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
47
+ }
48
+ // ]]>
49
+ </script>
50
+ </head>
51
+
52
+ <body>
53
+ <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
54
+ <td class="file-title"><span class="file-title-prefix">Module</span><br />PhusionPassenger::Railz</td>
55
+ <td align="right">
56
+ <table cellspacing="0" cellpadding="2">
57
+ <tr valign="top">
58
+ <td>In:</td>
59
+ <td>
60
+ <a href="../../files/lib/phusion_passenger/railz/application_spawner_rb.html">lib/phusion_passenger/railz/application_spawner.rb</a>
61
+ <a href="../../files/lib/phusion_passenger/railz/cgi_fixed_rb.html">lib/phusion_passenger/railz/cgi_fixed.rb</a>
62
+ <a href="../../files/lib/phusion_passenger/railz/framework_spawner_rb.html">lib/phusion_passenger/railz/framework_spawner.rb</a>
63
+ <a href="../../files/lib/phusion_passenger/railz/request_handler_rb.html">lib/phusion_passenger/railz/request_handler.rb</a>
64
+ </td>
65
+ </tr>
66
+ </table>
67
+ </td>
68
+ </tr>
69
+ </table>
70
+ <!-- banner header -->
71
+
72
+ <div id="bodyContent">
73
+ <div id="content">
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <div class="sectiontitle">Classes and Modules</div>
82
+ Class <a href="Railz/ApplicationSpawner.html" class="link">PhusionPassenger::Railz::ApplicationSpawner</a><br />
83
+ Class <a href="Railz/CGIFixed.html" class="link">PhusionPassenger::Railz::CGIFixed</a><br />
84
+ Class <a href="Railz/FrameworkSpawner.html" class="link">PhusionPassenger::Railz::FrameworkSpawner</a><br />
85
+ Class <a href="Railz/RequestHandler.html" class="link">PhusionPassenger::Railz::RequestHandler</a><br />
86
+
87
+
88
+
89
+
90
+ </div>
91
+
92
+ </div>
93
+
94
+ </body>
95
+ </html>
@@ -0,0 +1,442 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+ <html>
6
+ <head>
7
+ <title>Class: PhusionPassenger::Railz::ApplicationSpawner</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
10
+
11
+ <script language="JavaScript" type="text/javascript">
12
+ // <![CDATA[
13
+
14
+ function toggleSource( id )
15
+ {
16
+ var elem
17
+ var link
18
+
19
+ if( document.getElementById )
20
+ {
21
+ elem = document.getElementById( id )
22
+ link = document.getElementById( "l_" + id )
23
+ }
24
+ else if ( document.all )
25
+ {
26
+ elem = eval( "document.all." + id )
27
+ link = eval( "document.all.l_" + id )
28
+ }
29
+ else
30
+ return false;
31
+
32
+ if( elem.style.display == "block" )
33
+ {
34
+ elem.style.display = "none"
35
+ link.innerHTML = "show source"
36
+ }
37
+ else
38
+ {
39
+ elem.style.display = "block"
40
+ link.innerHTML = "hide source"
41
+ }
42
+ }
43
+
44
+ function openCode( url )
45
+ {
46
+ window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
47
+ }
48
+ // ]]>
49
+ </script>
50
+ </head>
51
+
52
+ <body>
53
+ <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
54
+ <td class="file-title"><span class="file-title-prefix">Class</span><br />PhusionPassenger::Railz::ApplicationSpawner</td>
55
+ <td align="right">
56
+ <table cellspacing="0" cellpadding="2">
57
+ <tr valign="top">
58
+ <td>In:</td>
59
+ <td>
60
+ <a href="../../../files/lib/phusion_passenger/railz/application_spawner_rb.html">lib/phusion_passenger/railz/application_spawner.rb</a>
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>Parent:</td>
65
+ <td>
66
+ AbstractServer
67
+ </td>
68
+ </tr>
69
+ </table>
70
+ </td>
71
+ </tr>
72
+ </table>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+ <div id="content">
77
+
78
+ <div class="description"><p>
79
+ This class is capable of spawning instances of a single Ruby on Rails
80
+ application. It does so by preloading as much of the application&#8216;s
81
+ code as possible, then creating instances of the application using what is
82
+ already preloaded. This makes it spawning application instances very fast,
83
+ except for the first spawn.
84
+ </p>
85
+ <p>
86
+ Use multiple instances of <a
87
+ href="ApplicationSpawner.html">ApplicationSpawner</a> if you need to spawn
88
+ multiple different Ruby on Rails applications.
89
+ </p>
90
+ <p>
91
+ <b>Note</b>: <a href="ApplicationSpawner.html">ApplicationSpawner</a> may
92
+ only be started asynchronously with <a
93
+ href="../AbstractServer.html#M000130">AbstractServer#start</a>. Starting it
94
+ synchronously with <a
95
+ href="../AbstractServer.html#M000131">AbstractServer#start_synchronously</a>
96
+ has not been tested.
97
+ </p>
98
+ </div>
99
+
100
+
101
+
102
+ <div class="sectiontitle">Methods</div>
103
+ <ul>
104
+ <li><a href="#M000048">new</a></li>
105
+ <li><a href="#M000049">spawn_application</a></li>
106
+ <li><a href="#M000050">spawn_application!</a></li>
107
+ <li><a href="#M000051">start</a></li>
108
+ </ul>
109
+
110
+ <div class="sectiontitle">Included Modules</div>
111
+ <ul>
112
+ <li><a href="../Utils.html">Utils</a></li>
113
+ </ul>
114
+
115
+
116
+ <div class="sectiontitle">Classes and Modules</div>
117
+ Class <a href="ApplicationSpawner/Error.html" class="link">PhusionPassenger::Railz::ApplicationSpawner::Error</a><br />
118
+
119
+
120
+ <div class="sectiontitle">Constants</div>
121
+ <table border='0' cellpadding='5'>
122
+ <tr valign='top'>
123
+ <td class="attr-name">ROOT_UID</td>
124
+ <td>=</td>
125
+ <td class="attr-value">0</td>
126
+ </tr>
127
+ <tr valign='top'>
128
+ <td>&nbsp;</td>
129
+ <td colspan="2" class="attr-desc">
130
+ The user ID of the root user.
131
+
132
+ </td>
133
+ </tr>
134
+ <tr valign='top'>
135
+ <td class="attr-name">ROOT_GID</td>
136
+ <td>=</td>
137
+ <td class="attr-value">0</td>
138
+ </tr>
139
+ <tr valign='top'>
140
+ <td>&nbsp;</td>
141
+ <td colspan="2" class="attr-desc">
142
+ The group ID of the root user.
143
+
144
+ </td>
145
+ </tr>
146
+ </table>
147
+
148
+ <div class="sectiontitle">Attributes</div>
149
+ <table border='0' cellpadding='5'>
150
+ <tr valign='top'>
151
+ <td class='attr-rw'>
152
+ [R]
153
+ </td>
154
+ <td class='attr-name'>app_root</td>
155
+ <td class='attr-desc'>
156
+ The application root of this spawner.
157
+
158
+ </td>
159
+ </tr>
160
+ </table>
161
+
162
+ <div class="sectiontitle">Public Class methods</div>
163
+ <div class="method">
164
+ <div class="title">
165
+ <a name="M000048"></a><b>new</b>(app_root, options = {})
166
+ </div>
167
+ <div class="description">
168
+ <p>
169
+ <tt>app_root</tt> is the root directory of this application, i.e. the
170
+ directory that contains &#8216;app/&#8217;, &#8216;public/&#8217;, etc. If
171
+ given an invalid directory, or a directory that doesn&#8216;t appear to be
172
+ a Rails application root directory, then an <a
173
+ href="../InvalidPath.html">InvalidPath</a> will be raised.
174
+ </p>
175
+ <p>
176
+ Additional options are:
177
+ </p>
178
+ <ul>
179
+ <li><tt>lower_privilege</tt> and <tt>lowest_user</tt>: If
180
+ <tt>lower_privilege</tt> is true, then <a
181
+ href="ApplicationSpawner.html">ApplicationSpawner</a> will attempt to
182
+ switch to the user who owns the application&#8216;s
183
+ <tt>config/environment.rb</tt>, and to the default group of that user.
184
+
185
+ <p>
186
+ If that user doesn&#8216;t exist on the system, or if that user is root,
187
+ then <a href="ApplicationSpawner.html">ApplicationSpawner</a> will attempt
188
+ to switch to the username given by <tt>lowest_user</tt> (and to the default
189
+ group of that user). If <tt>lowest_user</tt> doesn&#8216;t exist either, or
190
+ if switching user failed (because the current process does not have the
191
+ privilege to do so), then <a
192
+ href="ApplicationSpawner.html">ApplicationSpawner</a> will continue without
193
+ reporting an error.
194
+ </p>
195
+ </li>
196
+ <li><tt>environment</tt>: Allows one to specify the RAILS_ENV environment to
197
+ use.
198
+
199
+ </li>
200
+ <li><tt>environment_variables</tt>: Environment variables which should be
201
+ passed to the spawned application. This is NULL-seperated string of
202
+ key-value pairs, encoded in base64. The last byte in the unencoded data
203
+ must be a NULL.
204
+
205
+ </li>
206
+ <li><tt>base_uri</tt>: The base URI on which this application is deployed. It
207
+ equals &quot;/&quot; string if the application is deployed on the root URI.
208
+ It must not equal the empty string.
209
+
210
+ </li>
211
+ <li><tt>print_exceptions</tt>: Whether exceptions that have occurred during
212
+ application initialization should be printed to STDERR. The default is
213
+ true.
214
+
215
+ </li>
216
+ </ul>
217
+ <p>
218
+ All other options will be passed on to <a
219
+ href="RequestHandler.html">RequestHandler</a>.
220
+ </p>
221
+ </div>
222
+ <div class="sourcecode">
223
+ <p class="source-link">[ <a href="javascript:toggleSource('M000048_source')" id="l_M000048_source">show source</a> ]</p>
224
+ <div id="M000048_source" class="dyn-source">
225
+ <pre>
226
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/railz/application_spawner.rb, line 102</span>
227
+ 102: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app_root</span>, <span class="ruby-identifier">options</span> = {})
228
+ 103: <span class="ruby-keyword kw">super</span>()
229
+ 104: <span class="ruby-ivar">@app_root</span> = <span class="ruby-identifier">app_root</span>
230
+ 105: <span class="ruby-ivar">@canonicalized_app_root</span> = <span class="ruby-identifier">canonicalize_path</span>(<span class="ruby-identifier">app_root</span>)
231
+ 106: <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">sanitize_spawn_options</span>(<span class="ruby-identifier">options</span>)
232
+ 107: <span class="ruby-ivar">@lower_privilege</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value str">&quot;lower_privilege&quot;</span>]
233
+ 108: <span class="ruby-ivar">@lowest_user</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value str">&quot;lowest_user&quot;</span>]
234
+ 109: <span class="ruby-ivar">@environment</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value str">&quot;environment&quot;</span>]
235
+ 110: <span class="ruby-ivar">@encoded_environment_variables</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value str">&quot;environment_variables&quot;</span>]
236
+ 111: <span class="ruby-ivar">@base_uri</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value str">&quot;base_uri&quot;</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value str">&quot;base_uri&quot;</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value str">&quot;base_uri&quot;</span>] <span class="ruby-operator">!=</span> <span class="ruby-value str">&quot;/&quot;</span>
237
+ 112: <span class="ruby-ivar">@print_exceptions</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value str">&quot;print_exceptions&quot;</span>]
238
+ 113: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">max_idle_time</span> = <span class="ruby-constant">DEFAULT_APP_SPAWNER_MAX_IDLE_TIME</span>
239
+ 114: <span class="ruby-identifier">assert_valid_app_root</span>(<span class="ruby-ivar">@app_root</span>)
240
+ 115: <span class="ruby-identifier">define_message_handler</span>(<span class="ruby-identifier">:spawn_application</span>, <span class="ruby-identifier">:handle_spawn_application</span>)
241
+ 116: <span class="ruby-keyword kw">end</span>
242
+ </pre>
243
+ </div>
244
+ </div>
245
+ </div>
246
+ <div class="sectiontitle">Public Instance methods</div>
247
+ <div class="method">
248
+ <div class="title">
249
+ <a name="M000049"></a><b>spawn_application</b>()
250
+ </div>
251
+ <div class="description">
252
+ <p>
253
+ Spawn an instance of the RoR application. When successful, an <a
254
+ href="../Application.html">Application</a> object will be returned, which
255
+ represents the spawned RoR application.
256
+ </p>
257
+ <p>
258
+ Raises:
259
+ </p>
260
+ <ul>
261
+ <li><a
262
+ href="../AbstractServer/ServerNotStarted.html">AbstractServer::ServerNotStarted</a>:
263
+ The <a href="ApplicationSpawner.html">ApplicationSpawner</a> server
264
+ hasn&#8216;t already been started.
265
+
266
+ </li>
267
+ <li><a href="ApplicationSpawner/Error.html">ApplicationSpawner::Error</a>: The
268
+ <a href="ApplicationSpawner.html">ApplicationSpawner</a> server exited
269
+ unexpectedly.
270
+
271
+ </li>
272
+ </ul>
273
+ </div>
274
+ <div class="sourcecode">
275
+ <p class="source-link">[ <a href="javascript:toggleSource('M000049_source')" id="l_M000049_source">show source</a> ]</p>
276
+ <div id="M000049_source" class="dyn-source">
277
+ <pre>
278
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/railz/application_spawner.rb, line 124</span>
279
+ 124: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">spawn_application</span>
280
+ 125: <span class="ruby-identifier">server</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">&quot;spawn_application&quot;</span>)
281
+ 126: <span class="ruby-identifier">pid</span>, <span class="ruby-identifier">socket_name</span>, <span class="ruby-identifier">socket_type</span> = <span class="ruby-identifier">server</span>.<span class="ruby-identifier">read</span>
282
+ 127: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pid</span>.<span class="ruby-identifier">nil?</span>
283
+ 128: <span class="ruby-identifier">raise</span> <span class="ruby-constant">IOError</span>, <span class="ruby-value str">&quot;Connection closed&quot;</span>
284
+ 129: <span class="ruby-keyword kw">end</span>
285
+ 130: <span class="ruby-identifier">owner_pipe</span> = <span class="ruby-identifier">server</span>.<span class="ruby-identifier">recv_io</span>
286
+ 131: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Application</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@app_root</span>, <span class="ruby-identifier">pid</span>, <span class="ruby-identifier">socket_name</span>,
287
+ 132: <span class="ruby-identifier">socket_type</span>, <span class="ruby-identifier">owner_pipe</span>)
288
+ 133: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SystemCallError</span>, <span class="ruby-constant">IOError</span>, <span class="ruby-constant">SocketError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
289
+ 134: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Error</span>, <span class="ruby-node">&quot;The application spawner server exited unexpectedly: #{e}&quot;</span>
290
+ 135: <span class="ruby-keyword kw">end</span>
291
+ </pre>
292
+ </div>
293
+ </div>
294
+ </div>
295
+ <div class="method">
296
+ <div class="title">
297
+ <a name="M000050"></a><b>spawn_application!</b>()
298
+ </div>
299
+ <div class="description">
300
+ <p>
301
+ Spawn an instance of the RoR application. When successful, an <a
302
+ href="../Application.html">Application</a> object will be returned, which
303
+ represents the spawned RoR application.
304
+ </p>
305
+ <p>
306
+ Unlike <a href="ApplicationSpawner.html#M000049">spawn_application</a>,
307
+ this method may be called even when the <a
308
+ href="ApplicationSpawner.html">ApplicationSpawner</a> server isn&#8216;t
309
+ started. This allows one to spawn a RoR application without preloading any
310
+ source files.
311
+ </p>
312
+ <p>
313
+ This method may only be called if no Rails framework has been loaded in the
314
+ current Ruby VM.
315
+ </p>
316
+ <p>
317
+ Raises:
318
+ </p>
319
+ <ul>
320
+ <li><a href="../AppInitError.html">AppInitError</a>: The Ruby on Rails
321
+ application raised an exception or called exit() during startup.
322
+
323
+ </li>
324
+ <li>SystemCallError, IOError, SocketError: Something went wrong.
325
+
326
+ </li>
327
+ </ul>
328
+ </div>
329
+ <div class="sourcecode">
330
+ <p class="source-link">[ <a href="javascript:toggleSource('M000050_source')" id="l_M000050_source">show source</a> ]</p>
331
+ <div id="M000050_source" class="dyn-source">
332
+ <pre>
333
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/railz/application_spawner.rb, line 151</span>
334
+ 151: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">spawn_application!</span>
335
+ 152: <span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span> = <span class="ruby-constant">UNIXSocket</span>.<span class="ruby-identifier">pair</span>
336
+ 153: <span class="ruby-identifier">pid</span> = <span class="ruby-identifier">safe_fork</span>(<span class="ruby-value str">'application'</span>, <span class="ruby-keyword kw">true</span>) <span class="ruby-keyword kw">do</span>
337
+ 154: <span class="ruby-keyword kw">begin</span>
338
+ 155: <span class="ruby-identifier">a</span>.<span class="ruby-identifier">close</span>
339
+ 156:
340
+ 157: <span class="ruby-identifier">file_descriptors_to_leave_open</span> = [<span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">2</span>, <span class="ruby-identifier">b</span>.<span class="ruby-identifier">fileno</span>]
341
+ 158: <span class="ruby-constant">NativeSupport</span>.<span class="ruby-identifier">close_all_file_descriptors</span>(<span class="ruby-identifier">file_descriptors_to_leave_open</span>)
342
+ 159: <span class="ruby-identifier">close_all_io_objects_for_fds</span>(<span class="ruby-identifier">file_descriptors_to_leave_open</span>)
343
+ 160:
344
+ 161: <span class="ruby-identifier">channel</span> = <span class="ruby-constant">MessageChannel</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">b</span>)
345
+ 162: <span class="ruby-identifier">success</span> = <span class="ruby-identifier">report_app_init_status</span>(<span class="ruby-identifier">channel</span>) <span class="ruby-keyword kw">do</span>
346
+ 163: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'RAILS_ENV'</span>] = <span class="ruby-ivar">@environment</span>
347
+ 164: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'RAILS_RELATIVE_URL_ROOT'</span>] = <span class="ruby-ivar">@base_uri</span>
348
+ 165: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-ivar">@app_root</span>)
349
+ 166: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@encoded_environment_variables</span>
350
+ 167: <span class="ruby-identifier">set_passed_environment_variables</span>
351
+ 168: <span class="ruby-keyword kw">end</span>
352
+ 169: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@lower_privilege</span>
353
+ 170: <span class="ruby-identifier">lower_privilege</span>(<span class="ruby-value str">'config/environment.rb'</span>, <span class="ruby-ivar">@lowest_user</span>)
354
+ 171: <span class="ruby-keyword kw">end</span>
355
+ 172:
356
+ 173: <span class="ruby-comment cmt"># require Rails' environment, using the same path as the original rails dispatcher,</span>
357
+ 174: <span class="ruby-comment cmt"># which normally does: require File.dirname(__FILE__) + &quot;/../config/environment&quot;</span>
358
+ 175: <span class="ruby-comment cmt"># thus avoiding the possibility of including the same file twice.</span>
359
+ 176: <span class="ruby-identifier">require</span> <span class="ruby-value str">'public/../config/environment'</span>
360
+ 177:
361
+ 178: <span class="ruby-identifier">require</span> <span class="ruby-value str">'dispatcher'</span>
362
+ 179: <span class="ruby-keyword kw">end</span>
363
+ 180: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">success</span>
364
+ 181: <span class="ruby-identifier">start_request_handler</span>(<span class="ruby-identifier">channel</span>, <span class="ruby-keyword kw">false</span>)
365
+ 182: <span class="ruby-keyword kw">end</span>
366
+ 183: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SignalException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
367
+ 184: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">AbstractRequestHandler</span><span class="ruby-operator">::</span><span class="ruby-constant">HARD_TERMINATION_SIGNAL</span> <span class="ruby-operator">&amp;&amp;</span>
368
+ 185: <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">AbstractRequestHandler</span><span class="ruby-operator">::</span><span class="ruby-constant">SOFT_TERMINATION_SIGNAL</span>
369
+ 186: <span class="ruby-identifier">raise</span>
370
+ 187: <span class="ruby-keyword kw">end</span>
371
+ 188: <span class="ruby-keyword kw">end</span>
372
+ 189: <span class="ruby-keyword kw">end</span>
373
+ 190: <span class="ruby-identifier">b</span>.<span class="ruby-identifier">close</span>
374
+ 191: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid</span>(<span class="ruby-identifier">pid</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
375
+ 192:
376
+ 193: <span class="ruby-identifier">channel</span> = <span class="ruby-constant">MessageChannel</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">a</span>)
377
+ 194: <span class="ruby-identifier">unmarshal_and_raise_errors</span>(<span class="ruby-identifier">channel</span>, <span class="ruby-ivar">@print_exceptions</span>)
378
+ 195:
379
+ 196: <span class="ruby-comment cmt"># No exception was raised, so spawning succeeded.</span>
380
+ 197: <span class="ruby-identifier">pid</span>, <span class="ruby-identifier">socket_name</span>, <span class="ruby-identifier">socket_type</span> = <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">read</span>
381
+ 198: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pid</span>.<span class="ruby-identifier">nil?</span>
382
+ 199: <span class="ruby-identifier">raise</span> <span class="ruby-constant">IOError</span>, <span class="ruby-value str">&quot;Connection closed&quot;</span>
383
+ 200: <span class="ruby-keyword kw">end</span>
384
+ 201: <span class="ruby-identifier">owner_pipe</span> = <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">recv_io</span>
385
+ 202: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Application</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@app_root</span>, <span class="ruby-identifier">pid</span>, <span class="ruby-identifier">socket_name</span>,
386
+ 203: <span class="ruby-identifier">socket_type</span>, <span class="ruby-identifier">owner_pipe</span>)
387
+ 204: <span class="ruby-keyword kw">end</span>
388
+ </pre>
389
+ </div>
390
+ </div>
391
+ </div>
392
+ <div class="method">
393
+ <div class="title">
394
+ <a name="M000051"></a><b>start</b>()
395
+ </div>
396
+ <div class="description">
397
+ <p>
398
+ Overrided from <a
399
+ href="../AbstractServer.html#M000130">AbstractServer#start</a>.
400
+ </p>
401
+ <p>
402
+ May raise these additional exceptions:
403
+ </p>
404
+ <ul>
405
+ <li><a href="../AppInitError.html">AppInitError</a>: The Ruby on Rails
406
+ application raised an exception or called exit() during startup.
407
+
408
+ </li>
409
+ <li><a href="ApplicationSpawner/Error.html">ApplicationSpawner::Error</a>: The
410
+ <a href="ApplicationSpawner.html">ApplicationSpawner</a> server exited
411
+ unexpectedly.
412
+
413
+ </li>
414
+ </ul>
415
+ </div>
416
+ <div class="sourcecode">
417
+ <p class="source-link">[ <a href="javascript:toggleSource('M000051_source')" id="l_M000051_source">show source</a> ]</p>
418
+ <div id="M000051_source" class="dyn-source">
419
+ <pre>
420
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/railz/application_spawner.rb, line 212</span>
421
+ 212: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>
422
+ 213: <span class="ruby-keyword kw">super</span>
423
+ 214: <span class="ruby-keyword kw">begin</span>
424
+ 215: <span class="ruby-identifier">unmarshal_and_raise_errors</span>(<span class="ruby-identifier">server</span>, <span class="ruby-ivar">@print_exceptions</span>)
425
+ 216: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">IOError</span>, <span class="ruby-constant">SystemCallError</span>, <span class="ruby-constant">SocketError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
426
+ 217: <span class="ruby-identifier">stop</span>
427
+ 218: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Error</span>, <span class="ruby-node">&quot;The application spawner server exited unexpectedly: #{e}&quot;</span>
428
+ 219: <span class="ruby-keyword kw">rescue</span>
429
+ 220: <span class="ruby-identifier">stop</span>
430
+ 221: <span class="ruby-identifier">raise</span>
431
+ 222: <span class="ruby-keyword kw">end</span>
432
+ 223: <span class="ruby-keyword kw">end</span>
433
+ </pre>
434
+ </div>
435
+ </div>
436
+ </div>
437
+ </div>
438
+
439
+ </div>
440
+
441
+ </body>
442
+ </html>