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,125 @@
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::UnknownError</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::UnknownError</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/exceptions_rb.html">lib/phusion_passenger/exceptions.rb</a>
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>Parent:</td>
65
+ <td>
66
+ StandardError
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
+
79
+
80
+
81
+ <div class="sectiontitle">Methods</div>
82
+ <ul>
83
+ <li><a href="#M000125">new</a></li>
84
+ </ul>
85
+
86
+
87
+
88
+
89
+
90
+ <div class="sectiontitle">Attributes</div>
91
+ <table border='0' cellpadding='5'>
92
+ <tr valign='top'>
93
+ <td class='attr-rw'>
94
+ [RW]
95
+ </td>
96
+ <td class='attr-name'>real_class_name</td>
97
+ <td class='attr-desc'></td>
98
+ </tr>
99
+ </table>
100
+
101
+ <div class="sectiontitle">Public Class methods</div>
102
+ <div class="method">
103
+ <div class="title">
104
+ <a name="M000125"></a><b>new</b>(message, class_name, backtrace)
105
+ </div>
106
+ <div class="sourcecode">
107
+ <p class="source-link">[ <a href="javascript:toggleSource('M000125_source')" id="l_M000125_source">show source</a> ]</p>
108
+ <div id="M000125_source" class="dyn-source">
109
+ <pre>
110
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/exceptions.rb, line 93</span>
111
+ 93: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">message</span>, <span class="ruby-identifier">class_name</span>, <span class="ruby-identifier">backtrace</span>)
112
+ 94: <span class="ruby-keyword kw">super</span>(<span class="ruby-node">&quot;#{message} (#{class_name})&quot;</span>)
113
+ 95: <span class="ruby-identifier">set_backtrace</span>(<span class="ruby-identifier">backtrace</span>)
114
+ 96: <span class="ruby-ivar">@real_class_name</span> = <span class="ruby-identifier">class_name</span>
115
+ 97: <span class="ruby-keyword kw">end</span>
116
+ </pre>
117
+ </div>
118
+ </div>
119
+ </div>
120
+ </div>
121
+
122
+ </div>
123
+
124
+ </body>
125
+ </html>
@@ -0,0 +1,805 @@
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::Utils</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::Utils</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/utils_rb.html">lib/phusion_passenger/utils.rb</a>
61
+ </td>
62
+ </tr>
63
+ </table>
64
+ </td>
65
+ </tr>
66
+ </table>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+ <div id="content">
71
+
72
+ <div class="description"><p>
73
+ Utility functions.
74
+ </p>
75
+ </div>
76
+
77
+
78
+
79
+ <div class="sectiontitle">Methods</div>
80
+ <ul>
81
+ <li><a href="#M000075">assert_valid_app_root</a></li>
82
+ <li><a href="#M000076">assert_valid_directory</a></li>
83
+ <li><a href="#M000077">assert_valid_file</a></li>
84
+ <li><a href="#M000079">assert_valid_groupname</a></li>
85
+ <li><a href="#M000078">assert_valid_username</a></li>
86
+ <li><a href="#M000074">canonicalize_path</a></li>
87
+ <li><a href="#M000080">close_all_io_objects_for_fds</a></li>
88
+ <li><a href="#M000087">lower_privilege</a></li>
89
+ <li><a href="#M000081">marshal_exception</a></li>
90
+ <li><a href="#M000091">passenger_tmpdir</a></li>
91
+ <li><a href="#M000092">passenger_tmpdir</a></li>
92
+ <li><a href="#M000093">passenger_tmpdir=</a></li>
93
+ <li><a href="#M000083">print_exception</a></li>
94
+ <li><a href="#M000085">report_app_init_status</a></li>
95
+ <li><a href="#M000084">safe_fork</a></li>
96
+ <li><a href="#M000090">sanitize_spawn_options</a></li>
97
+ <li><a href="#M000088">switch_to_user</a></li>
98
+ <li><a href="#M000089">to_boolean</a></li>
99
+ <li><a href="#M000086">unmarshal_and_raise_errors</a></li>
100
+ <li><a href="#M000082">unmarshal_exception</a></li>
101
+ </ul>
102
+
103
+
104
+
105
+
106
+
107
+
108
+ <div class="sectiontitle">Protected Class methods</div>
109
+ <div class="method">
110
+ <div class="title">
111
+ <a name="M000092"></a><b>passenger_tmpdir</b>(create = true)
112
+ </div>
113
+ <div class="description">
114
+ <p>
115
+ Returns the directory in which to store Phusion Passenger-specific
116
+ temporary files. If <tt>create</tt> is true, then this method creates the
117
+ directory if it doesn&#8216;t exist.
118
+ </p>
119
+ </div>
120
+ <div class="sourcecode">
121
+ <p class="source-link">[ <a href="javascript:toggleSource('M000092_source')" id="l_M000092_source">show source</a> ]</p>
122
+ <div id="M000092_source" class="dyn-source">
123
+ <pre>
124
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 402</span>
125
+ 402: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">passenger_tmpdir</span>(<span class="ruby-identifier">create</span> = <span class="ruby-keyword kw">true</span>)
126
+ 403: <span class="ruby-identifier">dir</span> = <span class="ruby-ivar">@@passenger_tmpdir</span>
127
+ 404: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">empty?</span>
128
+ 405: <span class="ruby-identifier">dir</span> = <span class="ruby-node">&quot;#{Dir.tmpdir}/passenger.#{Process.pid}&quot;</span>
129
+ 406: <span class="ruby-ivar">@@passenger_tmpdir</span> = <span class="ruby-identifier">dir</span>
130
+ 407: <span class="ruby-keyword kw">end</span>
131
+ 408: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">create</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">dir</span>)
132
+ 409: <span class="ruby-comment cmt"># This is a very minimal implementation of the function</span>
133
+ 410: <span class="ruby-comment cmt"># passengerCreateTempDir() in Utils.cpp. This implementation</span>
134
+ 411: <span class="ruby-comment cmt"># is only meant to make the unit tests pass. For production</span>
135
+ 412: <span class="ruby-comment cmt"># systems one should pre-create the temp directory with</span>
136
+ 413: <span class="ruby-comment cmt"># passengerCreateTempDir().</span>
137
+ 414: <span class="ruby-identifier">system</span>(<span class="ruby-value str">&quot;mkdir&quot;</span>, <span class="ruby-value str">&quot;-p&quot;</span>, <span class="ruby-value str">&quot;-m&quot;</span>, <span class="ruby-value str">&quot;u=wxs,g=wx,o=wx&quot;</span>, <span class="ruby-identifier">dir</span>)
138
+ 415: <span class="ruby-identifier">system</span>(<span class="ruby-value str">&quot;mkdir&quot;</span>, <span class="ruby-value str">&quot;-p&quot;</span>, <span class="ruby-value str">&quot;-m&quot;</span>, <span class="ruby-value str">&quot;u=wxs,g=wx,o=wx&quot;</span>, <span class="ruby-node">&quot;#{dir}/backends&quot;</span>)
139
+ 416: <span class="ruby-keyword kw">end</span>
140
+ 417: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">dir</span>
141
+ 418: <span class="ruby-keyword kw">end</span>
142
+ </pre>
143
+ </div>
144
+ </div>
145
+ </div>
146
+ <div class="method">
147
+ <div class="title">
148
+ <a name="M000093"></a><b>passenger_tmpdir=</b>(dir)
149
+ </div>
150
+ <div class="sourcecode">
151
+ <p class="source-link">[ <a href="javascript:toggleSource('M000093_source')" id="l_M000093_source">show source</a> ]</p>
152
+ <div id="M000093_source" class="dyn-source">
153
+ <pre>
154
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 420</span>
155
+ 420: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">passenger_tmpdir=</span>(<span class="ruby-identifier">dir</span>)
156
+ 421: <span class="ruby-ivar">@@passenger_tmpdir</span> = <span class="ruby-identifier">dir</span>
157
+ 422: <span class="ruby-keyword kw">end</span>
158
+ </pre>
159
+ </div>
160
+ </div>
161
+ </div>
162
+ <div class="sectiontitle">Protected Instance methods</div>
163
+ <div class="method">
164
+ <div class="title">
165
+ <a name="M000075"></a><b>assert_valid_app_root</b>(app_root)
166
+ </div>
167
+ <div class="description">
168
+ <p>
169
+ Assert that <tt>app_root</tt> is a valid Ruby on Rails application root.
170
+ Raises <a href="InvalidPath.html">InvalidPath</a> if that is not the case.
171
+ </p>
172
+ </div>
173
+ <div class="sourcecode">
174
+ <p class="source-link">[ <a href="javascript:toggleSource('M000075_source')" id="l_M000075_source">show source</a> ]</p>
175
+ <div id="M000075_source" class="dyn-source">
176
+ <pre>
177
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 59</span>
178
+ 59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_valid_app_root</span>(<span class="ruby-identifier">app_root</span>)
179
+ 60: <span class="ruby-identifier">assert_valid_directory</span>(<span class="ruby-identifier">app_root</span>)
180
+ 61: <span class="ruby-identifier">assert_valid_file</span>(<span class="ruby-node">&quot;#{app_root}/config/environment.rb&quot;</span>)
181
+ 62: <span class="ruby-keyword kw">end</span>
182
+ </pre>
183
+ </div>
184
+ </div>
185
+ </div>
186
+ <div class="method">
187
+ <div class="title">
188
+ <a name="M000076"></a><b>assert_valid_directory</b>(path)
189
+ </div>
190
+ <div class="description">
191
+ <p>
192
+ Assert that <tt>path</tt> is a directory. Raises <tt><a
193
+ href="InvalidPath.html">InvalidPath</a></tt> if it isn&#8216;t.
194
+ </p>
195
+ </div>
196
+ <div class="sourcecode">
197
+ <p class="source-link">[ <a href="javascript:toggleSource('M000076_source')" id="l_M000076_source">show source</a> ]</p>
198
+ <div id="M000076_source" class="dyn-source">
199
+ <pre>
200
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 65</span>
201
+ 65: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_valid_directory</span>(<span class="ruby-identifier">path</span>)
202
+ 66: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">path</span>)
203
+ 67: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidPath</span>, <span class="ruby-node">&quot;'#{path}' is not a valid directory.&quot;</span>
204
+ 68: <span class="ruby-keyword kw">end</span>
205
+ 69: <span class="ruby-keyword kw">end</span>
206
+ </pre>
207
+ </div>
208
+ </div>
209
+ </div>
210
+ <div class="method">
211
+ <div class="title">
212
+ <a name="M000077"></a><b>assert_valid_file</b>(path)
213
+ </div>
214
+ <div class="description">
215
+ <p>
216
+ Assert that <tt>path</tt> is a file. Raises <tt><a
217
+ href="InvalidPath.html">InvalidPath</a></tt> if it isn&#8216;t.
218
+ </p>
219
+ </div>
220
+ <div class="sourcecode">
221
+ <p class="source-link">[ <a href="javascript:toggleSource('M000077_source')" id="l_M000077_source">show source</a> ]</p>
222
+ <div id="M000077_source" class="dyn-source">
223
+ <pre>
224
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 72</span>
225
+ 72: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_valid_file</span>(<span class="ruby-identifier">path</span>)
226
+ 73: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">path</span>)
227
+ 74: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidPath</span>, <span class="ruby-node">&quot;'#{path}' is not a valid file.&quot;</span>
228
+ 75: <span class="ruby-keyword kw">end</span>
229
+ 76: <span class="ruby-keyword kw">end</span>
230
+ </pre>
231
+ </div>
232
+ </div>
233
+ </div>
234
+ <div class="method">
235
+ <div class="title">
236
+ <a name="M000079"></a><b>assert_valid_groupname</b>(groupname)
237
+ </div>
238
+ <div class="description">
239
+ <p>
240
+ Assert that <tt>groupname</tt> is a valid group name. Raises ArgumentError
241
+ if that is not the case.
242
+ </p>
243
+ </div>
244
+ <div class="sourcecode">
245
+ <p class="source-link">[ <a href="javascript:toggleSource('M000079_source')" id="l_M000079_source">show source</a> ]</p>
246
+ <div id="M000079_source" class="dyn-source">
247
+ <pre>
248
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 87</span>
249
+ 87: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_valid_groupname</span>(<span class="ruby-identifier">groupname</span>)
250
+ 88: <span class="ruby-comment cmt"># If groupname does not exist then getgrnam() will raise an ArgumentError.</span>
251
+ 89: <span class="ruby-identifier">groupname</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">Etc</span>.<span class="ruby-identifier">getgrnam</span>(<span class="ruby-identifier">groupname</span>)
252
+ 90: <span class="ruby-keyword kw">end</span>
253
+ </pre>
254
+ </div>
255
+ </div>
256
+ </div>
257
+ <div class="method">
258
+ <div class="title">
259
+ <a name="M000078"></a><b>assert_valid_username</b>(username)
260
+ </div>
261
+ <div class="description">
262
+ <p>
263
+ Assert that <tt>username</tt> is a valid username. Raises ArgumentError if
264
+ that is not the case.
265
+ </p>
266
+ </div>
267
+ <div class="sourcecode">
268
+ <p class="source-link">[ <a href="javascript:toggleSource('M000078_source')" id="l_M000078_source">show source</a> ]</p>
269
+ <div id="M000078_source" class="dyn-source">
270
+ <pre>
271
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 80</span>
272
+ 80: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_valid_username</span>(<span class="ruby-identifier">username</span>)
273
+ 81: <span class="ruby-comment cmt"># If username does not exist then getpwnam() will raise an ArgumentError.</span>
274
+ 82: <span class="ruby-identifier">username</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">Etc</span>.<span class="ruby-identifier">getpwnam</span>(<span class="ruby-identifier">username</span>)
275
+ 83: <span class="ruby-keyword kw">end</span>
276
+ </pre>
277
+ </div>
278
+ </div>
279
+ </div>
280
+ <div class="method">
281
+ <div class="title">
282
+ <a name="M000074"></a><b>canonicalize_path</b>(path)
283
+ </div>
284
+ <div class="description">
285
+ <p>
286
+ Return the canonicalized version of <tt>path</tt>. This path is guaranteed
287
+ to to be &quot;normal&quot;, i.e. it doesn&#8216;t contain stuff like
288
+ &quot;..&quot; or &quot;/&quot;, and it fully resolves symbolic links.
289
+ </p>
290
+ <p>
291
+ Raises SystemCallError if something went wrong. Raises ArgumentError if
292
+ <tt>path</tt> is nil. Raises <a href="InvalidPath.html">InvalidPath</a> if
293
+ <tt>path</tt> does not appear to be a valid path.
294
+ </p>
295
+ </div>
296
+ <div class="sourcecode">
297
+ <p class="source-link">[ <a href="javascript:toggleSource('M000074_source')" id="l_M000074_source">show source</a> ]</p>
298
+ <div id="M000074_source" class="dyn-source">
299
+ <pre>
300
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 50</span>
301
+ 50: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">canonicalize_path</span>(<span class="ruby-identifier">path</span>)
302
+ 51: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">&quot;The 'path' argument may not be nil&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">nil?</span>
303
+ 52: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Pathname</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">realpath</span>.<span class="ruby-identifier">to_s</span>
304
+ 53: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
305
+ 54: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidAPath</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
306
+ 55: <span class="ruby-keyword kw">end</span>
307
+ </pre>
308
+ </div>
309
+ </div>
310
+ </div>
311
+ <div class="method">
312
+ <div class="title">
313
+ <a name="M000080"></a><b>close_all_io_objects_for_fds</b>(file_descriptors_to_leave_open)
314
+ </div>
315
+ <div class="sourcecode">
316
+ <p class="source-link">[ <a href="javascript:toggleSource('M000080_source')" id="l_M000080_source">show source</a> ]</p>
317
+ <div id="M000080_source" class="dyn-source">
318
+ <pre>
319
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 92</span>
320
+ 92: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close_all_io_objects_for_fds</span>(<span class="ruby-identifier">file_descriptors_to_leave_open</span>)
321
+ 93: <span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">each_object</span>(<span class="ruby-constant">IO</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">io</span><span class="ruby-operator">|</span>
322
+ 94: <span class="ruby-keyword kw">begin</span>
323
+ 95: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">file_descriptors_to_leave_open</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">io</span>.<span class="ruby-identifier">fileno</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">io</span>.<span class="ruby-identifier">closed?</span>
324
+ 96: <span class="ruby-identifier">io</span>.<span class="ruby-identifier">close</span>
325
+ 97: <span class="ruby-keyword kw">end</span>
326
+ 98: <span class="ruby-keyword kw">rescue</span>
327
+ 99: <span class="ruby-keyword kw">end</span>
328
+ 100: <span class="ruby-keyword kw">end</span>
329
+ 101: <span class="ruby-keyword kw">end</span>
330
+ </pre>
331
+ </div>
332
+ </div>
333
+ </div>
334
+ <div class="method">
335
+ <div class="title">
336
+ <a name="M000087"></a><b>lower_privilege</b>(filename, lowest_user = &quot;nobody&quot;)
337
+ </div>
338
+ <div class="description">
339
+ <p>
340
+ Lower the current process&#8216;s privilege to the owner of the given file.
341
+ No exceptions will be raised in the event that privilege lowering fails.
342
+ </p>
343
+ </div>
344
+ <div class="sourcecode">
345
+ <p class="source-link">[ <a href="javascript:toggleSource('M000087_source')" id="l_M000087_source">show source</a> ]</p>
346
+ <div id="M000087_source" class="dyn-source">
347
+ <pre>
348
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 325</span>
349
+ 325: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">lower_privilege</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">lowest_user</span> = <span class="ruby-value str">&quot;nobody&quot;</span>)
350
+ 326: <span class="ruby-identifier">stat</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">lstat</span>(<span class="ruby-identifier">filename</span>)
351
+ 327: <span class="ruby-keyword kw">begin</span>
352
+ 328: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">switch_to_user</span>(<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">uid</span>)
353
+ 329: <span class="ruby-identifier">switch_to_user</span>(<span class="ruby-identifier">lowest_user</span>)
354
+ 330: <span class="ruby-keyword kw">end</span>
355
+ 331: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EPERM</span>
356
+ 332: <span class="ruby-comment cmt"># No problem if we were unable to switch user.</span>
357
+ 333: <span class="ruby-keyword kw">end</span>
358
+ 334: <span class="ruby-keyword kw">end</span>
359
+ </pre>
360
+ </div>
361
+ </div>
362
+ </div>
363
+ <div class="method">
364
+ <div class="title">
365
+ <a name="M000081"></a><b>marshal_exception</b>(exception)
366
+ </div>
367
+ <div class="sourcecode">
368
+ <p class="source-link">[ <a href="javascript:toggleSource('M000081_source')" id="l_M000081_source">show source</a> ]</p>
369
+ <div id="M000081_source" class="dyn-source">
370
+ <pre>
371
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 103</span>
372
+ 103: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">marshal_exception</span>(<span class="ruby-identifier">exception</span>)
373
+ 104: <span class="ruby-identifier">data</span> = {
374
+ 105: <span class="ruby-identifier">:message</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">message</span>,
375
+ 106: <span class="ruby-identifier">:class</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>,
376
+ 107: <span class="ruby-identifier">:backtrace</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">backtrace</span>
377
+ 108: }
378
+ 109: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">InitializationError</span>)
379
+ 110: <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:is_initialization_error</span>] = <span class="ruby-keyword kw">true</span>
380
+ 111: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">child_exception</span>
381
+ 112: <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:child_exception</span>] = <span class="ruby-identifier">marshal_exception</span>(<span class="ruby-identifier">exception</span>.<span class="ruby-identifier">child_exception</span>)
382
+ 113: <span class="ruby-keyword kw">end</span>
383
+ 114: <span class="ruby-keyword kw">else</span>
384
+ 115: <span class="ruby-keyword kw">begin</span>
385
+ 116: <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:exception</span>] = <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-identifier">exception</span>)
386
+ 117: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-constant">TypeError</span>
387
+ 118: <span class="ruby-identifier">e</span> = <span class="ruby-constant">UnknownError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">exception</span>.<span class="ruby-identifier">message</span>, <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>,
388
+ 119: <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">backtrace</span>)
389
+ 120: <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:exception</span>] = <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-identifier">e</span>)
390
+ 121: <span class="ruby-keyword kw">end</span>
391
+ 122: <span class="ruby-keyword kw">end</span>
392
+ 123: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-identifier">data</span>)
393
+ 124: <span class="ruby-keyword kw">end</span>
394
+ </pre>
395
+ </div>
396
+ </div>
397
+ </div>
398
+ <div class="method">
399
+ <div class="title">
400
+ <a name="M000091"></a><b>passenger_tmpdir</b>(create = true)
401
+ </div>
402
+ <div class="sourcecode">
403
+ <p class="source-link">[ <a href="javascript:toggleSource('M000091_source')" id="l_M000091_source">show source</a> ]</p>
404
+ <div id="M000091_source" class="dyn-source">
405
+ <pre>
406
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 395</span>
407
+ 395: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">passenger_tmpdir</span>(<span class="ruby-identifier">create</span> = <span class="ruby-keyword kw">true</span>)
408
+ 396: <span class="ruby-constant">PhusionPassenger</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span>.<span class="ruby-identifier">passenger_tmpdir</span>(<span class="ruby-identifier">create</span>)
409
+ 397: <span class="ruby-keyword kw">end</span>
410
+ </pre>
411
+ </div>
412
+ </div>
413
+ </div>
414
+ <div class="method">
415
+ <div class="title">
416
+ <a name="M000083"></a><b>print_exception</b>(current_location, exception, destination = STDERR)
417
+ </div>
418
+ <div class="description">
419
+ <p>
420
+ Print the given exception, including the stack trace, to STDERR.
421
+ </p>
422
+ <p>
423
+ <tt>current_location</tt> is a string which describes where the code is
424
+ currently at. Usually the current class name will be enough.
425
+ </p>
426
+ </div>
427
+ <div class="sourcecode">
428
+ <p class="source-link">[ <a href="javascript:toggleSource('M000083_source')" id="l_M000083_source">show source</a> ]</p>
429
+ <div id="M000083_source" class="dyn-source">
430
+ <pre>
431
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 157</span>
432
+ 157: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print_exception</span>(<span class="ruby-identifier">current_location</span>, <span class="ruby-identifier">exception</span>, <span class="ruby-identifier">destination</span> = <span class="ruby-constant">STDERR</span>)
433
+ 158: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">exception</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">SystemExit</span>)
434
+ 159: <span class="ruby-identifier">destination</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">exception</span>.<span class="ruby-identifier">backtrace_string</span>(<span class="ruby-identifier">current_location</span>))
435
+ 160: <span class="ruby-identifier">destination</span>.<span class="ruby-identifier">flush</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">destination</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:flush</span>)
436
+ 161: <span class="ruby-keyword kw">end</span>
437
+ 162: <span class="ruby-keyword kw">end</span>
438
+ </pre>
439
+ </div>
440
+ </div>
441
+ </div>
442
+ <div class="method">
443
+ <div class="title">
444
+ <a name="M000085"></a><b>report_app_init_status</b>(channel, write_stderr_contents_to = STDERR) {|| ...}
445
+ </div>
446
+ <div class="description">
447
+ <p>
448
+ Run the given block. A message will be sent through <tt>channel</tt> (a <a
449
+ href="MessageChannel.html">MessageChannel</a> object), telling the remote
450
+ side whether the block raised an exception, called exit(), or succeeded.
451
+ </p>
452
+ <p>
453
+ Anything written to $stderr and STDERR during execution of the block will
454
+ be buffered. If <tt>write_stderr_contents_to</tt> is non-nil, then the
455
+ buffered stderr data will be written to this object. In this case,
456
+ <tt>write_stderr_contents_to</tt> must be an <a
457
+ href="../IO.html">IO</a>-like object. If <tt>write_stderr_contents_to</tt>
458
+ is nil, then the stder data will be discarded.
459
+ </p>
460
+ <p>
461
+ Returns whether the block succeeded, i.e. whether it didn&#8216;t raise an
462
+ exception.
463
+ </p>
464
+ <p>
465
+ Exceptions are not propagated, except SystemExit and a few
466
+ non-StandardExeption classes such as SignalException. Of the exceptions
467
+ that are propagated, only SystemExit will be reported.
468
+ </p>
469
+ </div>
470
+ <div class="sourcecode">
471
+ <p class="source-link">[ <a href="javascript:toggleSource('M000085_source')" id="l_M000085_source">show source</a> ]</p>
472
+ <div id="M000085_source" class="dyn-source">
473
+ <pre>
474
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 220</span>
475
+ 220: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">report_app_init_status</span>(<span class="ruby-identifier">channel</span>, <span class="ruby-identifier">write_stderr_contents_to</span> = <span class="ruby-constant">STDERR</span>)
476
+ 221: <span class="ruby-keyword kw">begin</span>
477
+ 222: <span class="ruby-identifier">old_global_stderr</span> = <span class="ruby-identifier">$stderr</span>
478
+ 223: <span class="ruby-identifier">old_stderr</span> = <span class="ruby-constant">STDERR</span>
479
+ 224: <span class="ruby-identifier">stderr_output</span> = <span class="ruby-value str">&quot;&quot;</span>
480
+ 225: <span class="ruby-identifier">tempfile</span> = <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'passenger-stderr'</span>)
481
+ 226: <span class="ruby-identifier">tempfile</span>.<span class="ruby-identifier">unlink</span>
482
+ 227: <span class="ruby-constant">Object</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:remove_const</span>, <span class="ruby-value str">'STDERR'</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
483
+ 228: <span class="ruby-constant">Object</span>.<span class="ruby-identifier">const_set</span>(<span class="ruby-value str">'STDERR'</span>, <span class="ruby-identifier">tempfile</span>)
484
+ 229: <span class="ruby-keyword kw">begin</span>
485
+ 230: <span class="ruby-keyword kw">yield</span>
486
+ 231: <span class="ruby-keyword kw">ensure</span>
487
+ 232: <span class="ruby-constant">Object</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:remove_const</span>, <span class="ruby-value str">'STDERR'</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
488
+ 233: <span class="ruby-constant">Object</span>.<span class="ruby-identifier">const_set</span>(<span class="ruby-value str">'STDERR'</span>, <span class="ruby-identifier">old_stderr</span>)
489
+ 234: <span class="ruby-identifier">$stderr</span> = <span class="ruby-identifier">old_global_stderr</span>
490
+ 235: <span class="ruby-identifier">tempfile</span>.<span class="ruby-identifier">rewind</span>
491
+ 236: <span class="ruby-identifier">stderr_output</span> = <span class="ruby-identifier">tempfile</span>.<span class="ruby-identifier">read</span>
492
+ 237: <span class="ruby-identifier">tempfile</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
493
+ 238:
494
+ 239: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">write_stderr_contents_to</span>
495
+ 240: <span class="ruby-identifier">write_stderr_contents_to</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">stderr_output</span>)
496
+ 241: <span class="ruby-identifier">write_stderr_contents_to</span>.<span class="ruby-identifier">flush</span>
497
+ 242: <span class="ruby-keyword kw">end</span>
498
+ 243: <span class="ruby-keyword kw">end</span>
499
+ 244: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">'success'</span>)
500
+ 245: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
501
+ 246: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">StandardError</span>, <span class="ruby-constant">ScriptError</span>, <span class="ruby-constant">NoMemoryError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
502
+ 247: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'TESTING_PASSENGER'</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'1'</span>
503
+ 248: <span class="ruby-identifier">print_exception</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">e</span>)
504
+ 249: <span class="ruby-keyword kw">end</span>
505
+ 250: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">'exception'</span>)
506
+ 251: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write_scalar</span>(<span class="ruby-identifier">marshal_exception</span>(<span class="ruby-identifier">e</span>))
507
+ 252: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write_scalar</span>(<span class="ruby-identifier">stderr_output</span>)
508
+ 253: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
509
+ 254: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SystemExit</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
510
+ 255: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">'exit'</span>)
511
+ 256: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write_scalar</span>(<span class="ruby-identifier">marshal_exception</span>(<span class="ruby-identifier">e</span>))
512
+ 257: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write_scalar</span>(<span class="ruby-identifier">stderr_output</span>)
513
+ 258: <span class="ruby-identifier">raise</span>
514
+ 259: <span class="ruby-keyword kw">end</span>
515
+ 260: <span class="ruby-keyword kw">end</span>
516
+ </pre>
517
+ </div>
518
+ </div>
519
+ </div>
520
+ <div class="method">
521
+ <div class="title">
522
+ <a name="M000084"></a><b>safe_fork</b>(current_location = self.class, double_fork = false) {|| ...}
523
+ </div>
524
+ <div class="description">
525
+ <p>
526
+ Fork a new process and run the given block inside the child process, just
527
+ like fork(). Unlike fork(), this method is safe, i.e. there&#8216;s no way
528
+ for the child process to escape the block. Any uncaught exceptions in the
529
+ child process will be printed to standard output, citing
530
+ <tt>current_location</tt> as the source. Futhermore, the child process will
531
+ exit by calling Kernel#exit!, thereby bypassing any at_exit or ensure
532
+ blocks.
533
+ </p>
534
+ <p>
535
+ If <tt>double_fork</tt> is true, then the child process will fork and
536
+ immediately exit. This technique can be used to avoid zombie processes, at
537
+ the expense of not being able to waitpid() the second child.
538
+ </p>
539
+ </div>
540
+ <div class="sourcecode">
541
+ <p class="source-link">[ <a href="javascript:toggleSource('M000084_source')" id="l_M000084_source">show source</a> ]</p>
542
+ <div id="M000084_source" class="dyn-source">
543
+ <pre>
544
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 174</span>
545
+ 174: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">safe_fork</span>(<span class="ruby-identifier">current_location</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">double_fork</span> = <span class="ruby-keyword kw">false</span>)
546
+ 175: <span class="ruby-identifier">pid</span> = <span class="ruby-identifier">fork</span>
547
+ 176: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pid</span>.<span class="ruby-identifier">nil?</span>
548
+ 177: <span class="ruby-keyword kw">begin</span>
549
+ 178: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">double_fork</span>
550
+ 179: <span class="ruby-identifier">pid2</span> = <span class="ruby-identifier">fork</span>
551
+ 180: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pid2</span>.<span class="ruby-identifier">nil?</span>
552
+ 181: <span class="ruby-identifier">srand</span>
553
+ 182: <span class="ruby-keyword kw">yield</span>
554
+ 183: <span class="ruby-keyword kw">end</span>
555
+ 184: <span class="ruby-keyword kw">else</span>
556
+ 185: <span class="ruby-identifier">srand</span>
557
+ 186: <span class="ruby-keyword kw">yield</span>
558
+ 187: <span class="ruby-keyword kw">end</span>
559
+ 188: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
560
+ 189: <span class="ruby-identifier">print_exception</span>(<span class="ruby-identifier">current_location</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">e</span>)
561
+ 190: <span class="ruby-keyword kw">ensure</span>
562
+ 191: <span class="ruby-identifier">exit!</span>
563
+ 192: <span class="ruby-keyword kw">end</span>
564
+ 193: <span class="ruby-keyword kw">else</span>
565
+ 194: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">double_fork</span>
566
+ 195: <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>
567
+ 196: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">pid</span>
568
+ 197: <span class="ruby-keyword kw">else</span>
569
+ 198: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">pid</span>
570
+ 199: <span class="ruby-keyword kw">end</span>
571
+ 200: <span class="ruby-keyword kw">end</span>
572
+ 201: <span class="ruby-keyword kw">end</span>
573
+ </pre>
574
+ </div>
575
+ </div>
576
+ </div>
577
+ <div class="method">
578
+ <div class="title">
579
+ <a name="M000090"></a><b>sanitize_spawn_options</b>(options)
580
+ </div>
581
+ <div class="sourcecode">
582
+ <p class="source-link">[ <a href="javascript:toggleSource('M000090_source')" id="l_M000090_source">show source</a> ]</p>
583
+ <div id="M000090_source" class="dyn-source">
584
+ <pre>
585
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 373</span>
586
+ 373: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sanitize_spawn_options</span>(<span class="ruby-identifier">options</span>)
587
+ 374: <span class="ruby-identifier">defaults</span> = {
588
+ 375: <span class="ruby-value str">&quot;lower_privilege&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
589
+ 376: <span class="ruby-value str">&quot;lowest_user&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;nobody&quot;</span>,
590
+ 377: <span class="ruby-value str">&quot;environment&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;production&quot;</span>,
591
+ 378: <span class="ruby-value str">&quot;app_type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;rails&quot;</span>,
592
+ 379: <span class="ruby-value str">&quot;spawn_method&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;smart-lv2&quot;</span>,
593
+ 380: <span class="ruby-value str">&quot;framework_spawner_timeout&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">-1</span>,
594
+ 381: <span class="ruby-value str">&quot;app_spawner_timeout&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">-1</span>,
595
+ 382: <span class="ruby-value str">&quot;print_exceptions&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>
596
+ 383: }
597
+ 384: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
598
+ 385: <span class="ruby-identifier">options</span>[<span class="ruby-value str">&quot;lower_privilege&quot;</span>] = <span class="ruby-identifier">to_boolean</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value str">&quot;lower_privilege&quot;</span>])
599
+ 386: <span class="ruby-identifier">options</span>[<span class="ruby-value str">&quot;framework_spawner_timeout&quot;</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">&quot;framework_spawner_timeout&quot;</span>].<span class="ruby-identifier">to_i</span>
600
+ 387: <span class="ruby-identifier">options</span>[<span class="ruby-value str">&quot;app_spawner_timeout&quot;</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">&quot;app_spawner_timeout&quot;</span>].<span class="ruby-identifier">to_i</span>
601
+ 388: <span class="ruby-comment cmt"># Force this to be a boolean for easy use with Utils#unmarshal_and_raise_errors.</span>
602
+ 389: <span class="ruby-identifier">options</span>[<span class="ruby-value str">&quot;print_exceptions&quot;</span>] = <span class="ruby-identifier">to_boolean</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value str">&quot;print_exceptions&quot;</span>])
603
+ 390: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">options</span>
604
+ 391: <span class="ruby-keyword kw">end</span>
605
+ </pre>
606
+ </div>
607
+ </div>
608
+ </div>
609
+ <div class="method">
610
+ <div class="title">
611
+ <a name="M000088"></a><b>switch_to_user</b>(user)
612
+ </div>
613
+ <div class="sourcecode">
614
+ <p class="source-link">[ <a href="javascript:toggleSource('M000088_source')" id="l_M000088_source">show source</a> ]</p>
615
+ <div id="M000088_source" class="dyn-source">
616
+ <pre>
617
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 336</span>
618
+ 336: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">switch_to_user</span>(<span class="ruby-identifier">user</span>)
619
+ 337: <span class="ruby-keyword kw">begin</span>
620
+ 338: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
621
+ 339: <span class="ruby-identifier">pw</span> = <span class="ruby-constant">Etc</span>.<span class="ruby-identifier">getpwnam</span>(<span class="ruby-identifier">user</span>)
622
+ 340: <span class="ruby-identifier">username</span> = <span class="ruby-identifier">user</span>
623
+ 341: <span class="ruby-identifier">uid</span> = <span class="ruby-identifier">pw</span>.<span class="ruby-identifier">uid</span>
624
+ 342: <span class="ruby-identifier">gid</span> = <span class="ruby-identifier">pw</span>.<span class="ruby-identifier">gid</span>
625
+ 343: <span class="ruby-keyword kw">else</span>
626
+ 344: <span class="ruby-identifier">pw</span> = <span class="ruby-constant">Etc</span>.<span class="ruby-identifier">getpwuid</span>(<span class="ruby-identifier">user</span>)
627
+ 345: <span class="ruby-identifier">username</span> = <span class="ruby-identifier">pw</span>.<span class="ruby-identifier">name</span>
628
+ 346: <span class="ruby-identifier">uid</span> = <span class="ruby-identifier">user</span>
629
+ 347: <span class="ruby-identifier">gid</span> = <span class="ruby-identifier">pw</span>.<span class="ruby-identifier">gid</span>
630
+ 348: <span class="ruby-keyword kw">end</span>
631
+ 349: <span class="ruby-keyword kw">rescue</span>
632
+ 350: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
633
+ 351: <span class="ruby-keyword kw">end</span>
634
+ 352: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uid</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
635
+ 353: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
636
+ 354: <span class="ruby-keyword kw">else</span>
637
+ 355: <span class="ruby-comment cmt"># Some systems are broken. initgroups can fail because of</span>
638
+ 356: <span class="ruby-comment cmt"># all kinds of stupid reasons. So we ignore any errors</span>
639
+ 357: <span class="ruby-comment cmt"># raised by initgroups.</span>
640
+ 358: <span class="ruby-keyword kw">begin</span>
641
+ 359: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">groups</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">initgroups</span>(<span class="ruby-identifier">username</span>, <span class="ruby-identifier">gid</span>)
642
+ 360: <span class="ruby-keyword kw">rescue</span>
643
+ 361: <span class="ruby-keyword kw">end</span>
644
+ 362: <span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-constant">Sys</span>.<span class="ruby-identifier">setgid</span>(<span class="ruby-identifier">gid</span>)
645
+ 363: <span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-constant">Sys</span>.<span class="ruby-identifier">setuid</span>(<span class="ruby-identifier">uid</span>)
646
+ 364: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'HOME'</span>] = <span class="ruby-identifier">pw</span>.<span class="ruby-identifier">dir</span>
647
+ 365: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
648
+ 366: <span class="ruby-keyword kw">end</span>
649
+ 367: <span class="ruby-keyword kw">end</span>
650
+ </pre>
651
+ </div>
652
+ </div>
653
+ </div>
654
+ <div class="method">
655
+ <div class="title">
656
+ <a name="M000089"></a><b>to_boolean</b>(value)
657
+ </div>
658
+ <div class="sourcecode">
659
+ <p class="source-link">[ <a href="javascript:toggleSource('M000089_source')" id="l_M000089_source">show source</a> ]</p>
660
+ <div id="M000089_source" class="dyn-source">
661
+ <pre>
662
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 369</span>
663
+ 369: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_boolean</span>(<span class="ruby-identifier">value</span>)
664
+ 370: <span class="ruby-keyword kw">return</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">value</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">value</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">value</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;false&quot;</span>)
665
+ 371: <span class="ruby-keyword kw">end</span>
666
+ </pre>
667
+ </div>
668
+ </div>
669
+ </div>
670
+ <div class="method">
671
+ <div class="title">
672
+ <a name="M000086"></a><b>unmarshal_and_raise_errors</b>(channel, print_exception = nil, app_type = &quot;rails&quot;)
673
+ </div>
674
+ <div class="description">
675
+ <p>
676
+ Receive status information that was sent to <tt>channel</tt> by <a
677
+ href="Utils.html#M000085">report_app_init_status</a>. If an error occured
678
+ according to the received information, then an appropriate exception will
679
+ be raised.
680
+ </p>
681
+ <p>
682
+ If <tt><a href="Utils.html#M000083">print_exception</a></tt> evaluates to
683
+ true, then the exception message and the backtrace will also be printed.
684
+ Where it is printed to depends on the type of <tt><a
685
+ href="Utils.html#M000083">print_exception</a></tt>:
686
+ </p>
687
+ <ul>
688
+ <li>If it responds to #puts, then the exception information will be printed
689
+ using this method.
690
+
691
+ </li>
692
+ <li>If it responds to #to_str, then the exception information will be appended
693
+ to the file whose filename equals the return value of the #to_str call.
694
+
695
+ </li>
696
+ <li>Otherwise, it will be printed to STDERR.
697
+
698
+ </li>
699
+ </ul>
700
+ <p>
701
+ Raises:
702
+ </p>
703
+ <ul>
704
+ <li><a href="AppInitError.html">AppInitError</a>: this class wraps the
705
+ exception information received through the channel.
706
+
707
+ </li>
708
+ <li>IOError, SystemCallError, SocketError: these errors are raised if an error
709
+ occurred while receiving the information through the channel.
710
+
711
+ </li>
712
+ </ul>
713
+ </div>
714
+ <div class="sourcecode">
715
+ <p class="source-link">[ <a href="javascript:toggleSource('M000086_source')" id="l_M000086_source">show source</a> ]</p>
716
+ <div id="M000086_source" class="dyn-source">
717
+ <pre>
718
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 284</span>
719
+ 284: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unmarshal_and_raise_errors</span>(<span class="ruby-identifier">channel</span>, <span class="ruby-identifier">print_exception</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">app_type</span> = <span class="ruby-value str">&quot;rails&quot;</span>)
720
+ 285: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">read</span>
721
+ 286: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
722
+ 287: <span class="ruby-identifier">raise</span> <span class="ruby-constant">EOFError</span>, <span class="ruby-value str">&quot;Unexpected end-of-file detected.&quot;</span>
723
+ 288: <span class="ruby-keyword kw">end</span>
724
+ 289: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]
725
+ 290: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'exception'</span>
726
+ 291: <span class="ruby-identifier">child_exception</span> = <span class="ruby-identifier">unmarshal_exception</span>(<span class="ruby-identifier">channel</span>.<span class="ruby-identifier">read_scalar</span>)
727
+ 292: <span class="ruby-identifier">stderr</span> = <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">read_scalar</span>
728
+ 293: <span class="ruby-identifier">exception</span> = <span class="ruby-constant">AppInitError</span>.<span class="ruby-identifier">new</span>(
729
+ 294: <span class="ruby-node">&quot;Application '#{@app_root}' raised an exception: &quot;</span> <span class="ruby-operator">&lt;&lt;</span>
730
+ 295: <span class="ruby-node">&quot;#{child_exception.class} (#{child_exception.message})&quot;</span>,
731
+ 296: <span class="ruby-identifier">child_exception</span>,
732
+ 297: <span class="ruby-identifier">app_type</span>,
733
+ 298: <span class="ruby-identifier">stderr</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">stderr</span>)
734
+ 299: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'exit'</span>
735
+ 300: <span class="ruby-identifier">child_exception</span> = <span class="ruby-identifier">unmarshal_exception</span>(<span class="ruby-identifier">channel</span>.<span class="ruby-identifier">read_scalar</span>)
736
+ 301: <span class="ruby-identifier">stderr</span> = <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">read_scalar</span>
737
+ 302: <span class="ruby-identifier">exception</span> = <span class="ruby-constant">AppInitError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Application '#{@app_root}' exited during startup&quot;</span>,
738
+ 303: <span class="ruby-identifier">child_exception</span>, <span class="ruby-identifier">app_type</span>, <span class="ruby-identifier">stderr</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">stderr</span>)
739
+ 304: <span class="ruby-keyword kw">else</span>
740
+ 305: <span class="ruby-identifier">exception</span> = <span class="ruby-keyword kw">nil</span>
741
+ 306: <span class="ruby-keyword kw">end</span>
742
+ 307:
743
+ 308: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">print_exception</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">exception</span>
744
+ 309: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">print_exception</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:puts</span>)
745
+ 310: <span class="ruby-identifier">print_exception</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">child_exception</span>, <span class="ruby-identifier">print_exception</span>)
746
+ 311: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">print_exception</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_str</span>)
747
+ 312: <span class="ruby-identifier">filename</span> = <span class="ruby-identifier">print_exception</span>.<span class="ruby-identifier">to_str</span>
748
+ 313: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-value str">'a'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
749
+ 314: <span class="ruby-identifier">print_exception</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">child_exception</span>, <span class="ruby-identifier">f</span>)
750
+ 315: <span class="ruby-keyword kw">end</span>
751
+ 316: <span class="ruby-keyword kw">else</span>
752
+ 317: <span class="ruby-identifier">print_exception</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">child_exception</span>)
753
+ 318: <span class="ruby-keyword kw">end</span>
754
+ 319: <span class="ruby-keyword kw">end</span>
755
+ 320: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">exception</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">exception</span>
756
+ 321: <span class="ruby-keyword kw">end</span>
757
+ </pre>
758
+ </div>
759
+ </div>
760
+ </div>
761
+ <div class="method">
762
+ <div class="title">
763
+ <a name="M000082"></a><b>unmarshal_exception</b>(data)
764
+ </div>
765
+ <div class="sourcecode">
766
+ <p class="source-link">[ <a href="javascript:toggleSource('M000082_source')" id="l_M000082_source">show source</a> ]</p>
767
+ <div id="M000082_source" class="dyn-source">
768
+ <pre>
769
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 126</span>
770
+ 126: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unmarshal_exception</span>(<span class="ruby-identifier">data</span>)
771
+ 127: <span class="ruby-identifier">hash</span> = <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">data</span>)
772
+ 128: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:is_initialization_error</span>]
773
+ 129: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:child_exception</span>]
774
+ 130: <span class="ruby-identifier">child_exception</span> = <span class="ruby-identifier">unmarshal_exception</span>(<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:child_exception</span>])
775
+ 131: <span class="ruby-keyword kw">else</span>
776
+ 132: <span class="ruby-identifier">child_exception</span> = <span class="ruby-keyword kw">nil</span>
777
+ 133: <span class="ruby-keyword kw">end</span>
778
+ 134:
779
+ 135: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:class</span>]
780
+ 136: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">AppInitError</span>.<span class="ruby-identifier">to_s</span>
781
+ 137: <span class="ruby-identifier">exception_class</span> = <span class="ruby-constant">AppInitError</span>
782
+ 138: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">FrameworkInitError</span>.<span class="ruby-identifier">to_s</span>
783
+ 139: <span class="ruby-identifier">exception_class</span> = <span class="ruby-constant">FrameworkInitError</span>
784
+ 140: <span class="ruby-keyword kw">else</span>
785
+ 141: <span class="ruby-identifier">exception_class</span> = <span class="ruby-constant">InitializationError</span>
786
+ 142: <span class="ruby-keyword kw">end</span>
787
+ 143: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">exception_class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:message</span>], <span class="ruby-identifier">child_exception</span>)
788
+ 144: <span class="ruby-keyword kw">else</span>
789
+ 145: <span class="ruby-keyword kw">begin</span>
790
+ 146: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:exception</span>])
791
+ 147: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-constant">TypeError</span>
792
+ 148: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">UnknownError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:message</span>], <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:class</span>], <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:backtrace</span>])
793
+ 149: <span class="ruby-keyword kw">end</span>
794
+ 150: <span class="ruby-keyword kw">end</span>
795
+ 151: <span class="ruby-keyword kw">end</span>
796
+ </pre>
797
+ </div>
798
+ </div>
799
+ </div>
800
+ </div>
801
+
802
+ </div>
803
+
804
+ </body>
805
+ </html>