passenger 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- data/Rakefile +66 -79
- data/bin/passenger-install-nginx-module +1 -1
- data/bin/passenger-memory-stats +1 -1
- data/bin/passenger-spawn-server +8 -2
- data/doc/Users guide Apache.html +33 -49
- data/doc/Users guide Apache.txt +28 -27
- data/doc/Users guide Nginx.html +9 -19
- data/doc/Users guide Nginx.txt +8 -20
- data/doc/cxxapi/Bucket_8h-source.html +1 -1
- data/doc/cxxapi/Configuration_8h-source.html +297 -300
- data/doc/cxxapi/DirectoryMapper_8h-source.html +1 -1
- data/doc/cxxapi/Hooks_8h-source.html +1 -1
- data/doc/cxxapi/annotated.html +1 -1
- data/doc/cxxapi/classHooks-members.html +1 -1
- data/doc/cxxapi/classHooks.html +1 -1
- data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +1 -1
- data/doc/cxxapi/classes.html +1 -1
- data/doc/cxxapi/definitions_8h-source.html +1 -1
- data/doc/cxxapi/files.html +1 -1
- data/doc/cxxapi/functions.html +1 -1
- data/doc/cxxapi/functions_func.html +1 -1
- data/doc/cxxapi/graph_legend.html +1 -1
- data/doc/cxxapi/group__Configuration.html +1 -23
- data/doc/cxxapi/group__Core.html +1 -1
- data/doc/cxxapi/group__Hooks.html +1 -1
- data/doc/cxxapi/group__Support.html +1 -1
- data/doc/cxxapi/main.html +1 -1
- data/doc/cxxapi/modules.html +1 -1
- data/doc/users_guide_snippets/rackup_specifications.txt +4 -2
- data/ext/apache2/Configuration.h +0 -3
- data/ext/apache2/Hooks.cpp +5 -3
- data/ext/common/ApplicationPoolServer.h +1 -0
- data/ext/common/ApplicationPoolServerExecutable.cpp +5 -2
- data/ext/common/SpawnManager.h +1 -0
- data/ext/common/Utils.cpp +22 -23
- data/ext/common/Utils.h +32 -21
- data/ext/common/Version.h +31 -0
- data/ext/nginx/ContentHandler.c +61 -8
- data/ext/nginx/HelperServer.cpp +3 -0
- data/ext/nginx/HttpStatusExtractor.h +185 -0
- data/ext/nginx/StaticContentHandler.c +18 -3
- data/ext/nginx/config +2 -1
- data/ext/nginx/ngx_http_passenger_module.c +21 -15
- data/ext/oxt/backtrace.cpp +4 -2
- data/ext/oxt/spin_lock.hpp +3 -3
- data/lib/phusion_passenger/abstract_request_handler.rb +5 -3
- data/lib/phusion_passenger/admin_tools/control_process.rb +6 -1
- data/lib/phusion_passenger/constants.rb +2 -2
- data/lib/phusion_passenger/rack/application_spawner.rb +2 -1
- data/lib/phusion_passenger/rack/request_handler.rb +45 -35
- data/lib/phusion_passenger/templates/nginx/config_snippets.txt.erb +1 -1
- data/lib/phusion_passenger/utils.rb +13 -3
- data/misc/rake/cplusplus.rb +7 -0
- data/test/ApplicationPoolServer_ApplicationPoolTest.cpp +2 -0
- data/test/ApplicationPoolTest.cpp +39 -62
- data/test/CxxTestMain.cpp +6 -6
- data/test/HttpStatusExtractorTest.cpp +17 -0
- data/test/StandardApplicationPoolTest.cpp +2 -0
- data/test/UtilsTest.cpp +17 -28
- data/test/ruby/abstract_request_handler_spec.rb +3 -7
- data/test/ruby/utils_spec.rb +18 -13
- data/test/ruby/wsgi/application_spawner_spec.rb +5 -9
- data/test/stub/railsapp/app/controllers/{bar_controller_1.rb → bar_controller.rb} +0 -0
- data/test/stub/railsapp/app/controllers/bar_controller_1.txt +5 -0
- data/test/stub/railsapp/app/controllers/{bar_controller_2.rb → bar_controller_2.txt} +0 -0
- data/test/support/Support.h +20 -0
- data/test/support/config.rb +13 -0
- data/vendor/README +4 -3
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/COPYING +1 -1
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/KNOWN-ISSUES +0 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/README +54 -7
- data/vendor/rack-1.0.0-git/Rakefile +164 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack.rb +7 -3
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/adapter/camping.rb +0 -0
- data/vendor/rack-1.0.0-git/lib/rack/auth/abstract/handler.rb +37 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/abstract/request.rb +0 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/basic.rb +0 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/digest/md5.rb +1 -1
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/digest/nonce.rb +0 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/digest/params.rb +0 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/digest/request.rb +2 -2
- data/vendor/rack-1.0.0-git/lib/rack/auth/openid.rb +480 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/builder.rb +1 -5
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/cascade.rb +0 -0
- data/vendor/rack-1.0.0-git/lib/rack/chunked.rb +49 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/commonlogger.rb +0 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/conditionalget.rb +4 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/content_length.rb +7 -3
- data/vendor/rack-1.0.0-git/lib/rack/content_type.rb +23 -0
- data/vendor/rack-1.0.0-git/lib/rack/deflater.rb +96 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/directory.rb +5 -2
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/file.rb +4 -1
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler.rb +22 -1
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/cgi.rb +7 -3
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/evented_mongrel.rb +0 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/fastcgi.rb +26 -24
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/lsws.rb +7 -4
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/mongrel.rb +5 -3
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/scgi.rb +5 -3
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/swiftiplied_mongrel.rb +0 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/thin.rb +3 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/webrick.rb +11 -5
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/head.rb +0 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/lint.rb +138 -66
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/lobster.rb +0 -0
- data/vendor/rack-1.0.0-git/lib/rack/lock.rb +16 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/methodoverride.rb +0 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/mime.rb +4 -4
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/mock.rb +42 -5
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/recursive.rb +0 -0
- data/vendor/rack-1.0.0-git/lib/rack/reloader.rb +106 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/request.rb +46 -10
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/response.rb +15 -3
- data/vendor/rack-1.0.0-git/lib/rack/rewindable_input.rb +98 -0
- data/vendor/rack-1.0.0-git/lib/rack/session/abstract/id.rb +142 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/session/cookie.rb +2 -0
- data/vendor/rack-1.0.0-git/lib/rack/session/memcache.rb +109 -0
- data/vendor/rack-1.0.0-git/lib/rack/session/pool.rb +100 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/showexceptions.rb +2 -1
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/showstatus.rb +1 -1
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/static.rb +0 -0
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/urlmap.rb +12 -5
- data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/utils.rb +212 -65
- metadata +71 -170
- data/doc/rdoc/classes/ConditionVariable.html +0 -194
- data/doc/rdoc/classes/Exception.html +0 -120
- data/doc/rdoc/classes/GC.html +0 -113
- data/doc/rdoc/classes/IO.html +0 -169
- data/doc/rdoc/classes/PhusionPassenger.html +0 -238
- data/doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html +0 -153
- data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +0 -506
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer.html +0 -692
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerAlreadyStarted.html +0 -97
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerError.html +0 -96
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerNotStarted.html +0 -97
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer/UnknownMessage.html +0 -96
- data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +0 -598
- data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +0 -140
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess.html +0 -264
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess/Instance.html +0 -138
- data/doc/rdoc/classes/PhusionPassenger/AppInitError.html +0 -154
- data/doc/rdoc/classes/PhusionPassenger/Application.html +0 -283
- data/doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html +0 -172
- data/doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html +0 -145
- data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +0 -175
- data/doc/rdoc/classes/PhusionPassenger/InitializationError.html +0 -141
- data/doc/rdoc/classes/PhusionPassenger/InvalidPath.html +0 -92
- data/doc/rdoc/classes/PhusionPassenger/MessageChannel.html +0 -489
- data/doc/rdoc/classes/PhusionPassenger/NativeSupport.html +0 -350
- data/doc/rdoc/classes/PhusionPassenger/Rack.html +0 -91
- data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +0 -185
- data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +0 -184
- data/doc/rdoc/classes/PhusionPassenger/Railz.html +0 -95
- data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +0 -419
- data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner/Error.html +0 -98
- data/doc/rdoc/classes/PhusionPassenger/Railz/CGIFixed.html +0 -200
- data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +0 -443
- data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner/Error.html +0 -98
- data/doc/rdoc/classes/PhusionPassenger/Railz/RequestHandler.html +0 -154
- data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +0 -402
- data/doc/rdoc/classes/PhusionPassenger/UnknownError.html +0 -125
- data/doc/rdoc/classes/PhusionPassenger/Utils.html +0 -694
- data/doc/rdoc/classes/PhusionPassenger/VersionNotFound.html +0 -140
- data/doc/rdoc/classes/PhusionPassenger/WSGI.html +0 -89
- data/doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html +0 -188
- data/doc/rdoc/classes/PlatformInfo.html +0 -831
- data/doc/rdoc/classes/RakeExtensions.html +0 -197
- data/doc/rdoc/classes/Signal.html +0 -134
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/DEVELOPERS_TXT.html +0 -240
- data/doc/rdoc/files/README.html +0 -157
- data/doc/rdoc/files/ext/phusion_passenger/native_support_c.html +0 -92
- data/doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html +0 -129
- data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +0 -131
- data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +0 -126
- data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +0 -130
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +0 -129
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +0 -122
- data/doc/rdoc/files/lib/phusion_passenger/application_rb.html +0 -127
- data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +0 -126
- data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +0 -122
- data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +0 -134
- data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +0 -122
- data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +0 -122
- data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +0 -126
- data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +0 -122
- data/doc/rdoc/files/lib/phusion_passenger/packaging_rb.html +0 -122
- data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +0 -127
- data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +0 -133
- data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +0 -126
- data/doc/rdoc/files/lib/phusion_passenger/railz/application_spawner_rb.html +0 -143
- data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +0 -126
- data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +0 -145
- data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +0 -127
- data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +0 -122
- data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +0 -161
- data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +0 -175
- data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +0 -129
- data/doc/rdoc/files/misc/rake/extensions_rb.html +0 -130
- data/doc/rdoc/fr_class_index.html +0 -90
- data/doc/rdoc/fr_file_index.html +0 -76
- data/doc/rdoc/fr_method_index.html +0 -195
- data/doc/rdoc/index.html +0 -26
- data/doc/rdoc/rdoc-style.css +0 -187
- data/vendor/rack-0.9.1/AUTHORS +0 -8
- data/vendor/rack-0.9.1/ChangeLog +0 -1423
- data/vendor/rack-0.9.1/Rakefile +0 -188
- data/vendor/rack-0.9.1/SPEC +0 -129
- data/vendor/rack-0.9.1/lib/rack/auth/abstract/handler.rb +0 -28
- data/vendor/rack-0.9.1/lib/rack/auth/openid.rb +0 -438
- data/vendor/rack-0.9.1/lib/rack/deflater.rb +0 -87
- data/vendor/rack-0.9.1/lib/rack/reloader.rb +0 -64
- data/vendor/rack-0.9.1/lib/rack/session/abstract/id.rb +0 -153
- data/vendor/rack-0.9.1/lib/rack/session/memcache.rb +0 -97
- data/vendor/rack-0.9.1/lib/rack/session/pool.rb +0 -73
@@ -1,125 +0,0 @@
|
|
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="#M000121">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="M000121"></a><b>new</b>(message, class_name, backtrace)
|
105
|
-
</div>
|
106
|
-
<div class="sourcecode">
|
107
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000121_source')" id="l_M000121_source">show source</a> ]</p>
|
108
|
-
<div id="M000121_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">"#{message} (#{class_name})"</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>
|
@@ -1,694 +0,0 @@
|
|
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="#M000074">assert_valid_app_root</a></li>
|
82
|
-
<li><a href="#M000075">assert_valid_directory</a></li>
|
83
|
-
<li><a href="#M000076">assert_valid_file</a></li>
|
84
|
-
<li><a href="#M000078">assert_valid_groupname</a></li>
|
85
|
-
<li><a href="#M000077">assert_valid_username</a></li>
|
86
|
-
<li><a href="#M000073">canonicalize_path</a></li>
|
87
|
-
<li><a href="#M000079">close_all_io_objects_for_fds</a></li>
|
88
|
-
<li><a href="#M000086">lower_privilege</a></li>
|
89
|
-
<li><a href="#M000080">marshal_exception</a></li>
|
90
|
-
<li><a href="#M000089">passenger_tmpdir</a></li>
|
91
|
-
<li><a href="#M000082">print_exception</a></li>
|
92
|
-
<li><a href="#M000084">report_app_init_status</a></li>
|
93
|
-
<li><a href="#M000083">safe_fork</a></li>
|
94
|
-
<li><a href="#M000088">sanitize_spawn_options</a></li>
|
95
|
-
<li><a href="#M000087">switch_to_user</a></li>
|
96
|
-
<li><a href="#M000085">unmarshal_and_raise_errors</a></li>
|
97
|
-
<li><a href="#M000081">unmarshal_exception</a></li>
|
98
|
-
</ul>
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
<div class="sectiontitle">Protected Instance methods</div>
|
106
|
-
<div class="method">
|
107
|
-
<div class="title">
|
108
|
-
<a name="M000074"></a><b>assert_valid_app_root</b>(app_root)
|
109
|
-
</div>
|
110
|
-
<div class="description">
|
111
|
-
<p>
|
112
|
-
Assert that <tt>app_root</tt> is a valid Ruby on Rails application root.
|
113
|
-
Raises <a href="InvalidPath.html">InvalidPath</a> if that is not the case.
|
114
|
-
</p>
|
115
|
-
</div>
|
116
|
-
<div class="sourcecode">
|
117
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000074_source')" id="l_M000074_source">show source</a> ]</p>
|
118
|
-
<div id="M000074_source" class="dyn-source">
|
119
|
-
<pre>
|
120
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 59</span>
|
121
|
-
59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_valid_app_root</span>(<span class="ruby-identifier">app_root</span>)
|
122
|
-
60: <span class="ruby-identifier">assert_valid_directory</span>(<span class="ruby-identifier">app_root</span>)
|
123
|
-
61: <span class="ruby-identifier">assert_valid_file</span>(<span class="ruby-node">"#{app_root}/config/environment.rb"</span>)
|
124
|
-
62: <span class="ruby-keyword kw">end</span>
|
125
|
-
</pre>
|
126
|
-
</div>
|
127
|
-
</div>
|
128
|
-
</div>
|
129
|
-
<div class="method">
|
130
|
-
<div class="title">
|
131
|
-
<a name="M000075"></a><b>assert_valid_directory</b>(path)
|
132
|
-
</div>
|
133
|
-
<div class="description">
|
134
|
-
<p>
|
135
|
-
Assert that <tt>path</tt> is a directory. Raises <tt><a
|
136
|
-
href="InvalidPath.html">InvalidPath</a></tt> if it isn‘t.
|
137
|
-
</p>
|
138
|
-
</div>
|
139
|
-
<div class="sourcecode">
|
140
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000075_source')" id="l_M000075_source">show source</a> ]</p>
|
141
|
-
<div id="M000075_source" class="dyn-source">
|
142
|
-
<pre>
|
143
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 65</span>
|
144
|
-
65: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_valid_directory</span>(<span class="ruby-identifier">path</span>)
|
145
|
-
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>)
|
146
|
-
67: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidPath</span>, <span class="ruby-node">"'#{path}' is not a valid directory."</span>
|
147
|
-
68: <span class="ruby-keyword kw">end</span>
|
148
|
-
69: <span class="ruby-keyword kw">end</span>
|
149
|
-
</pre>
|
150
|
-
</div>
|
151
|
-
</div>
|
152
|
-
</div>
|
153
|
-
<div class="method">
|
154
|
-
<div class="title">
|
155
|
-
<a name="M000076"></a><b>assert_valid_file</b>(path)
|
156
|
-
</div>
|
157
|
-
<div class="description">
|
158
|
-
<p>
|
159
|
-
Assert that <tt>path</tt> is a file. Raises <tt><a
|
160
|
-
href="InvalidPath.html">InvalidPath</a></tt> if it isn‘t.
|
161
|
-
</p>
|
162
|
-
</div>
|
163
|
-
<div class="sourcecode">
|
164
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000076_source')" id="l_M000076_source">show source</a> ]</p>
|
165
|
-
<div id="M000076_source" class="dyn-source">
|
166
|
-
<pre>
|
167
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 72</span>
|
168
|
-
72: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_valid_file</span>(<span class="ruby-identifier">path</span>)
|
169
|
-
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>)
|
170
|
-
74: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidPath</span>, <span class="ruby-node">"'#{path}' is not a valid file."</span>
|
171
|
-
75: <span class="ruby-keyword kw">end</span>
|
172
|
-
76: <span class="ruby-keyword kw">end</span>
|
173
|
-
</pre>
|
174
|
-
</div>
|
175
|
-
</div>
|
176
|
-
</div>
|
177
|
-
<div class="method">
|
178
|
-
<div class="title">
|
179
|
-
<a name="M000078"></a><b>assert_valid_groupname</b>(groupname)
|
180
|
-
</div>
|
181
|
-
<div class="description">
|
182
|
-
<p>
|
183
|
-
Assert that <tt>groupname</tt> is a valid group name. Raises ArgumentError
|
184
|
-
if that is not the case.
|
185
|
-
</p>
|
186
|
-
</div>
|
187
|
-
<div class="sourcecode">
|
188
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000078_source')" id="l_M000078_source">show source</a> ]</p>
|
189
|
-
<div id="M000078_source" class="dyn-source">
|
190
|
-
<pre>
|
191
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 87</span>
|
192
|
-
87: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_valid_groupname</span>(<span class="ruby-identifier">groupname</span>)
|
193
|
-
88: <span class="ruby-comment cmt"># If groupname does not exist then getgrnam() will raise an ArgumentError.</span>
|
194
|
-
89: <span class="ruby-identifier">groupname</span> <span class="ruby-operator">&&</span> <span class="ruby-constant">Etc</span>.<span class="ruby-identifier">getgrnam</span>(<span class="ruby-identifier">groupname</span>)
|
195
|
-
90: <span class="ruby-keyword kw">end</span>
|
196
|
-
</pre>
|
197
|
-
</div>
|
198
|
-
</div>
|
199
|
-
</div>
|
200
|
-
<div class="method">
|
201
|
-
<div class="title">
|
202
|
-
<a name="M000077"></a><b>assert_valid_username</b>(username)
|
203
|
-
</div>
|
204
|
-
<div class="description">
|
205
|
-
<p>
|
206
|
-
Assert that <tt>username</tt> is a valid username. Raises ArgumentError if
|
207
|
-
that is not the case.
|
208
|
-
</p>
|
209
|
-
</div>
|
210
|
-
<div class="sourcecode">
|
211
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000077_source')" id="l_M000077_source">show source</a> ]</p>
|
212
|
-
<div id="M000077_source" class="dyn-source">
|
213
|
-
<pre>
|
214
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 80</span>
|
215
|
-
80: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_valid_username</span>(<span class="ruby-identifier">username</span>)
|
216
|
-
81: <span class="ruby-comment cmt"># If username does not exist then getpwnam() will raise an ArgumentError.</span>
|
217
|
-
82: <span class="ruby-identifier">username</span> <span class="ruby-operator">&&</span> <span class="ruby-constant">Etc</span>.<span class="ruby-identifier">getpwnam</span>(<span class="ruby-identifier">username</span>)
|
218
|
-
83: <span class="ruby-keyword kw">end</span>
|
219
|
-
</pre>
|
220
|
-
</div>
|
221
|
-
</div>
|
222
|
-
</div>
|
223
|
-
<div class="method">
|
224
|
-
<div class="title">
|
225
|
-
<a name="M000073"></a><b>canonicalize_path</b>(path)
|
226
|
-
</div>
|
227
|
-
<div class="description">
|
228
|
-
<p>
|
229
|
-
Return the canonicalized version of <tt>path</tt>. This path is guaranteed
|
230
|
-
to to be "normal", i.e. it doesn‘t contain stuff like
|
231
|
-
".." or "/", and it fully resolves symbolic links.
|
232
|
-
</p>
|
233
|
-
<p>
|
234
|
-
Raises SystemCallError if something went wrong. Raises ArgumentError if
|
235
|
-
<tt>path</tt> is nil. Raises <a href="InvalidPath.html">InvalidPath</a> if
|
236
|
-
<tt>path</tt> does not appear to be a valid path.
|
237
|
-
</p>
|
238
|
-
</div>
|
239
|
-
<div class="sourcecode">
|
240
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000073_source')" id="l_M000073_source">show source</a> ]</p>
|
241
|
-
<div id="M000073_source" class="dyn-source">
|
242
|
-
<pre>
|
243
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 50</span>
|
244
|
-
50: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">canonicalize_path</span>(<span class="ruby-identifier">path</span>)
|
245
|
-
51: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"The 'path' argument may not be nil"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">nil?</span>
|
246
|
-
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>
|
247
|
-
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">></span> <span class="ruby-identifier">e</span>
|
248
|
-
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>
|
249
|
-
55: <span class="ruby-keyword kw">end</span>
|
250
|
-
</pre>
|
251
|
-
</div>
|
252
|
-
</div>
|
253
|
-
</div>
|
254
|
-
<div class="method">
|
255
|
-
<div class="title">
|
256
|
-
<a name="M000079"></a><b>close_all_io_objects_for_fds</b>(file_descriptors_to_leave_open)
|
257
|
-
</div>
|
258
|
-
<div class="sourcecode">
|
259
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000079_source')" id="l_M000079_source">show source</a> ]</p>
|
260
|
-
<div id="M000079_source" class="dyn-source">
|
261
|
-
<pre>
|
262
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 92</span>
|
263
|
-
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>)
|
264
|
-
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>
|
265
|
-
94: <span class="ruby-keyword kw">begin</span>
|
266
|
-
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">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">io</span>.<span class="ruby-identifier">closed?</span>
|
267
|
-
96: <span class="ruby-identifier">io</span>.<span class="ruby-identifier">close</span>
|
268
|
-
97: <span class="ruby-keyword kw">end</span>
|
269
|
-
98: <span class="ruby-keyword kw">rescue</span>
|
270
|
-
99: <span class="ruby-keyword kw">end</span>
|
271
|
-
100: <span class="ruby-keyword kw">end</span>
|
272
|
-
101: <span class="ruby-keyword kw">end</span>
|
273
|
-
</pre>
|
274
|
-
</div>
|
275
|
-
</div>
|
276
|
-
</div>
|
277
|
-
<div class="method">
|
278
|
-
<div class="title">
|
279
|
-
<a name="M000086"></a><b>lower_privilege</b>(filename, lowest_user = "nobody")
|
280
|
-
</div>
|
281
|
-
<div class="description">
|
282
|
-
<p>
|
283
|
-
Lower the current process‘s privilege to the owner of the given file.
|
284
|
-
No exceptions will be raised in the event that privilege lowering fails.
|
285
|
-
</p>
|
286
|
-
</div>
|
287
|
-
<div class="sourcecode">
|
288
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000086_source')" id="l_M000086_source">show source</a> ]</p>
|
289
|
-
<div id="M000086_source" class="dyn-source">
|
290
|
-
<pre>
|
291
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 279</span>
|
292
|
-
279: <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">"nobody"</span>)
|
293
|
-
280: <span class="ruby-identifier">stat</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">lstat</span>(<span class="ruby-identifier">filename</span>)
|
294
|
-
281: <span class="ruby-keyword kw">begin</span>
|
295
|
-
282: <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>)
|
296
|
-
283: <span class="ruby-identifier">switch_to_user</span>(<span class="ruby-identifier">lowest_user</span>)
|
297
|
-
284: <span class="ruby-keyword kw">end</span>
|
298
|
-
285: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EPERM</span>
|
299
|
-
286: <span class="ruby-comment cmt"># No problem if we were unable to switch user.</span>
|
300
|
-
287: <span class="ruby-keyword kw">end</span>
|
301
|
-
288: <span class="ruby-keyword kw">end</span>
|
302
|
-
</pre>
|
303
|
-
</div>
|
304
|
-
</div>
|
305
|
-
</div>
|
306
|
-
<div class="method">
|
307
|
-
<div class="title">
|
308
|
-
<a name="M000080"></a><b>marshal_exception</b>(exception)
|
309
|
-
</div>
|
310
|
-
<div class="sourcecode">
|
311
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000080_source')" id="l_M000080_source">show source</a> ]</p>
|
312
|
-
<div id="M000080_source" class="dyn-source">
|
313
|
-
<pre>
|
314
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 103</span>
|
315
|
-
103: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">marshal_exception</span>(<span class="ruby-identifier">exception</span>)
|
316
|
-
104: <span class="ruby-identifier">data</span> = {
|
317
|
-
105: <span class="ruby-identifier">:message</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">message</span>,
|
318
|
-
106: <span class="ruby-identifier">:class</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>,
|
319
|
-
107: <span class="ruby-identifier">:backtrace</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">backtrace</span>
|
320
|
-
108: }
|
321
|
-
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>)
|
322
|
-
110: <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:is_initialization_error</span>] = <span class="ruby-keyword kw">true</span>
|
323
|
-
111: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">child_exception</span>
|
324
|
-
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>)
|
325
|
-
113: <span class="ruby-keyword kw">end</span>
|
326
|
-
114: <span class="ruby-keyword kw">else</span>
|
327
|
-
115: <span class="ruby-keyword kw">begin</span>
|
328
|
-
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>)
|
329
|
-
117: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-constant">TypeError</span>
|
330
|
-
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>,
|
331
|
-
119: <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">backtrace</span>)
|
332
|
-
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>)
|
333
|
-
121: <span class="ruby-keyword kw">end</span>
|
334
|
-
122: <span class="ruby-keyword kw">end</span>
|
335
|
-
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>)
|
336
|
-
124: <span class="ruby-keyword kw">end</span>
|
337
|
-
</pre>
|
338
|
-
</div>
|
339
|
-
</div>
|
340
|
-
</div>
|
341
|
-
<div class="method">
|
342
|
-
<div class="title">
|
343
|
-
<a name="M000089"></a><b>passenger_tmpdir</b>(create = true)
|
344
|
-
</div>
|
345
|
-
<div class="description">
|
346
|
-
<p>
|
347
|
-
Returns the directory in which to store Phusion Passenger-specific
|
348
|
-
temporary files. If <tt>create</tt> is true, then this method creates the
|
349
|
-
directory if it doesn‘t exist.
|
350
|
-
</p>
|
351
|
-
</div>
|
352
|
-
<div class="sourcecode">
|
353
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000089_source')" id="l_M000089_source">show source</a> ]</p>
|
354
|
-
<div id="M000089_source" class="dyn-source">
|
355
|
-
<pre>
|
356
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 343</span>
|
357
|
-
343: <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>)
|
358
|
-
344: <span class="ruby-identifier">dir</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PASSENGER_INSTANCE_TEMP_DIR'</span>]
|
359
|
-
345: <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>
|
360
|
-
346: <span class="ruby-identifier">dir</span> = <span class="ruby-node">"#{Dir.tmpdir}/passenger.#{Process.pid}"</span>
|
361
|
-
347: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PASSENGER_INSTANCE_TEMP_DIR'</span>] = <span class="ruby-identifier">dir</span>
|
362
|
-
348: <span class="ruby-keyword kw">end</span>
|
363
|
-
349: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">create</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">dir</span>)
|
364
|
-
350: <span class="ruby-comment cmt"># This is a very minimal implementation of the function</span>
|
365
|
-
351: <span class="ruby-comment cmt"># passengerCreateTempDir() in Utils.cpp. This implementation</span>
|
366
|
-
352: <span class="ruby-comment cmt"># is only meant to make the unit tests pass. For production</span>
|
367
|
-
353: <span class="ruby-comment cmt"># systems one should pre-create the temp directory with</span>
|
368
|
-
354: <span class="ruby-comment cmt"># passengerCreateTempDir().</span>
|
369
|
-
355: <span class="ruby-identifier">system</span>(<span class="ruby-value str">"mkdir"</span>, <span class="ruby-value str">"-p"</span>, <span class="ruby-value str">"-m"</span>, <span class="ruby-value str">"u=wxs,g=wx,o=wx"</span>, <span class="ruby-identifier">dir</span>)
|
370
|
-
356: <span class="ruby-identifier">system</span>(<span class="ruby-value str">"mkdir"</span>, <span class="ruby-value str">"-p"</span>, <span class="ruby-value str">"-m"</span>, <span class="ruby-value str">"u=wxs,g=wx,o=wx"</span>, <span class="ruby-node">"#{dir}/backends"</span>)
|
371
|
-
357: <span class="ruby-keyword kw">end</span>
|
372
|
-
358: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">dir</span>
|
373
|
-
359: <span class="ruby-keyword kw">end</span>
|
374
|
-
</pre>
|
375
|
-
</div>
|
376
|
-
</div>
|
377
|
-
</div>
|
378
|
-
<div class="method">
|
379
|
-
<div class="title">
|
380
|
-
<a name="M000082"></a><b>print_exception</b>(current_location, exception)
|
381
|
-
</div>
|
382
|
-
<div class="description">
|
383
|
-
<p>
|
384
|
-
Print the given exception, including the stack trace, to STDERR.
|
385
|
-
</p>
|
386
|
-
<p>
|
387
|
-
<tt>current_location</tt> is a string which describes where the code is
|
388
|
-
currently at. Usually the current class name will be enough.
|
389
|
-
</p>
|
390
|
-
</div>
|
391
|
-
<div class="sourcecode">
|
392
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000082_source')" id="l_M000082_source">show source</a> ]</p>
|
393
|
-
<div id="M000082_source" class="dyn-source">
|
394
|
-
<pre>
|
395
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 157</span>
|
396
|
-
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>)
|
397
|
-
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>)
|
398
|
-
159: <span class="ruby-constant">STDERR</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>))
|
399
|
-
160: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">flush</span>
|
400
|
-
161: <span class="ruby-keyword kw">end</span>
|
401
|
-
162: <span class="ruby-keyword kw">end</span>
|
402
|
-
</pre>
|
403
|
-
</div>
|
404
|
-
</div>
|
405
|
-
</div>
|
406
|
-
<div class="method">
|
407
|
-
<div class="title">
|
408
|
-
<a name="M000084"></a><b>report_app_init_status</b>(channel) {|| ...}
|
409
|
-
</div>
|
410
|
-
<div class="description">
|
411
|
-
<p>
|
412
|
-
Run the given block. A message will be sent through <tt>channel</tt> (a <a
|
413
|
-
href="MessageChannel.html">MessageChannel</a> object), telling the remote
|
414
|
-
side whether the block raised an exception, called exit(), or succeeded.
|
415
|
-
Returns whether the block succeeded. Exceptions are not propagated, except
|
416
|
-
for SystemExit.
|
417
|
-
</p>
|
418
|
-
</div>
|
419
|
-
<div class="sourcecode">
|
420
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000084_source')" id="l_M000084_source">show source</a> ]</p>
|
421
|
-
<div id="M000084_source" class="dyn-source">
|
422
|
-
<pre>
|
423
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 206</span>
|
424
|
-
206: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">report_app_init_status</span>(<span class="ruby-identifier">channel</span>)
|
425
|
-
207: <span class="ruby-keyword kw">begin</span>
|
426
|
-
208: <span class="ruby-identifier">old_global_stderr</span> = <span class="ruby-identifier">$stderr</span>
|
427
|
-
209: <span class="ruby-identifier">old_stderr</span> = <span class="ruby-constant">STDERR</span>
|
428
|
-
210: <span class="ruby-identifier">stderr_output</span> = <span class="ruby-value str">""</span>
|
429
|
-
211: <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>)
|
430
|
-
212: <span class="ruby-identifier">tempfile</span>.<span class="ruby-identifier">unlink</span>
|
431
|
-
213: <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>
|
432
|
-
214: <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>)
|
433
|
-
215: <span class="ruby-keyword kw">begin</span>
|
434
|
-
216: <span class="ruby-keyword kw">yield</span>
|
435
|
-
217: <span class="ruby-keyword kw">ensure</span>
|
436
|
-
218: <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>
|
437
|
-
219: <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>)
|
438
|
-
220: <span class="ruby-identifier">$stderr</span> = <span class="ruby-identifier">old_global_stderr</span>
|
439
|
-
221: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tempfile</span>
|
440
|
-
222: <span class="ruby-identifier">tempfile</span>.<span class="ruby-identifier">rewind</span>
|
441
|
-
223: <span class="ruby-identifier">stderr_output</span> = <span class="ruby-identifier">tempfile</span>.<span class="ruby-identifier">read</span>
|
442
|
-
224: <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>
|
443
|
-
225: <span class="ruby-keyword kw">end</span>
|
444
|
-
226: <span class="ruby-keyword kw">end</span>
|
445
|
-
227: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">'success'</span>)
|
446
|
-
228: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
447
|
-
229: <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">></span> <span class="ruby-identifier">e</span>
|
448
|
-
230: <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>
|
449
|
-
231: <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>)
|
450
|
-
232: <span class="ruby-keyword kw">end</span>
|
451
|
-
233: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">'exception'</span>)
|
452
|
-
234: <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>))
|
453
|
-
235: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write_scalar</span>(<span class="ruby-identifier">stderr_output</span>)
|
454
|
-
236: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
455
|
-
237: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SystemExit</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
456
|
-
238: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">'exit'</span>)
|
457
|
-
239: <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>))
|
458
|
-
240: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">write_scalar</span>(<span class="ruby-identifier">stderr_output</span>)
|
459
|
-
241: <span class="ruby-identifier">raise</span>
|
460
|
-
242: <span class="ruby-keyword kw">end</span>
|
461
|
-
243: <span class="ruby-keyword kw">end</span>
|
462
|
-
</pre>
|
463
|
-
</div>
|
464
|
-
</div>
|
465
|
-
</div>
|
466
|
-
<div class="method">
|
467
|
-
<div class="title">
|
468
|
-
<a name="M000083"></a><b>safe_fork</b>(current_location = self.class, double_fork = false) {|| ...}
|
469
|
-
</div>
|
470
|
-
<div class="description">
|
471
|
-
<p>
|
472
|
-
Fork a new process and run the given block inside the child process, just
|
473
|
-
like fork(). Unlike fork(), this method is safe, i.e. there‘s no way
|
474
|
-
for the child process to escape the block. Any uncaught exceptions in the
|
475
|
-
child process will be printed to standard output, citing
|
476
|
-
<tt>current_location</tt> as the source. Futhermore, the child process will
|
477
|
-
exit by calling Kernel#exit!, thereby bypassing any at_exit or ensure
|
478
|
-
blocks.
|
479
|
-
</p>
|
480
|
-
<p>
|
481
|
-
If <tt>double_fork</tt> is true, then the child process will fork and
|
482
|
-
immediately exit. This technique can be used to avoid zombie processes, at
|
483
|
-
the expense of not being able to waitpid() the second child.
|
484
|
-
</p>
|
485
|
-
</div>
|
486
|
-
<div class="sourcecode">
|
487
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000083_source')" id="l_M000083_source">show source</a> ]</p>
|
488
|
-
<div id="M000083_source" class="dyn-source">
|
489
|
-
<pre>
|
490
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 174</span>
|
491
|
-
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>)
|
492
|
-
175: <span class="ruby-identifier">pid</span> = <span class="ruby-identifier">fork</span>
|
493
|
-
176: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pid</span>.<span class="ruby-identifier">nil?</span>
|
494
|
-
177: <span class="ruby-keyword kw">begin</span>
|
495
|
-
178: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">double_fork</span>
|
496
|
-
179: <span class="ruby-identifier">pid2</span> = <span class="ruby-identifier">fork</span>
|
497
|
-
180: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pid2</span>.<span class="ruby-identifier">nil?</span>
|
498
|
-
181: <span class="ruby-keyword kw">yield</span>
|
499
|
-
182: <span class="ruby-keyword kw">end</span>
|
500
|
-
183: <span class="ruby-keyword kw">else</span>
|
501
|
-
184: <span class="ruby-keyword kw">yield</span>
|
502
|
-
185: <span class="ruby-keyword kw">end</span>
|
503
|
-
186: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
504
|
-
187: <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>)
|
505
|
-
188: <span class="ruby-keyword kw">ensure</span>
|
506
|
-
189: <span class="ruby-identifier">exit!</span>
|
507
|
-
190: <span class="ruby-keyword kw">end</span>
|
508
|
-
191: <span class="ruby-keyword kw">else</span>
|
509
|
-
192: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">double_fork</span>
|
510
|
-
193: <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>
|
511
|
-
194: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">pid</span>
|
512
|
-
195: <span class="ruby-keyword kw">else</span>
|
513
|
-
196: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">pid</span>
|
514
|
-
197: <span class="ruby-keyword kw">end</span>
|
515
|
-
198: <span class="ruby-keyword kw">end</span>
|
516
|
-
199: <span class="ruby-keyword kw">end</span>
|
517
|
-
</pre>
|
518
|
-
</div>
|
519
|
-
</div>
|
520
|
-
</div>
|
521
|
-
<div class="method">
|
522
|
-
<div class="title">
|
523
|
-
<a name="M000088"></a><b>sanitize_spawn_options</b>(options)
|
524
|
-
</div>
|
525
|
-
<div class="sourcecode">
|
526
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000088_source')" id="l_M000088_source">show source</a> ]</p>
|
527
|
-
<div id="M000088_source" class="dyn-source">
|
528
|
-
<pre>
|
529
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 323</span>
|
530
|
-
323: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sanitize_spawn_options</span>(<span class="ruby-identifier">options</span>)
|
531
|
-
324: <span class="ruby-identifier">defaults</span> = {
|
532
|
-
325: <span class="ruby-value str">"lower_privilege"</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>,
|
533
|
-
326: <span class="ruby-value str">"lowest_user"</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"nobody"</span>,
|
534
|
-
327: <span class="ruby-value str">"environment"</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"production"</span>,
|
535
|
-
328: <span class="ruby-value str">"app_type"</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"rails"</span>,
|
536
|
-
329: <span class="ruby-value str">"spawn_method"</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"smart-lv2"</span>,
|
537
|
-
330: <span class="ruby-value str">"framework_spawner_timeout"</span> =<span class="ruby-operator">></span> <span class="ruby-value">-1</span>,
|
538
|
-
331: <span class="ruby-value str">"app_spawner_timeout"</span> =<span class="ruby-operator">></span> <span class="ruby-value">-1</span>
|
539
|
-
332: }
|
540
|
-
333: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
|
541
|
-
334: <span class="ruby-identifier">options</span>[<span class="ruby-value str">"lower_privilege"</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">"lower_privilege"</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"true"</span>
|
542
|
-
335: <span class="ruby-identifier">options</span>[<span class="ruby-value str">"framework_spawner_timeout"</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">"framework_spawner_timeout"</span>].<span class="ruby-identifier">to_i</span>
|
543
|
-
336: <span class="ruby-identifier">options</span>[<span class="ruby-value str">"app_spawner_timeout"</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">"app_spawner_timeout"</span>].<span class="ruby-identifier">to_i</span>
|
544
|
-
337: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">options</span>
|
545
|
-
338: <span class="ruby-keyword kw">end</span>
|
546
|
-
</pre>
|
547
|
-
</div>
|
548
|
-
</div>
|
549
|
-
</div>
|
550
|
-
<div class="method">
|
551
|
-
<div class="title">
|
552
|
-
<a name="M000087"></a><b>switch_to_user</b>(user)
|
553
|
-
</div>
|
554
|
-
<div class="sourcecode">
|
555
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000087_source')" id="l_M000087_source">show source</a> ]</p>
|
556
|
-
<div id="M000087_source" class="dyn-source">
|
557
|
-
<pre>
|
558
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 290</span>
|
559
|
-
290: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">switch_to_user</span>(<span class="ruby-identifier">user</span>)
|
560
|
-
291: <span class="ruby-keyword kw">begin</span>
|
561
|
-
292: <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>)
|
562
|
-
293: <span class="ruby-identifier">pw</span> = <span class="ruby-constant">Etc</span>.<span class="ruby-identifier">getpwnam</span>(<span class="ruby-identifier">user</span>)
|
563
|
-
294: <span class="ruby-identifier">username</span> = <span class="ruby-identifier">user</span>
|
564
|
-
295: <span class="ruby-identifier">uid</span> = <span class="ruby-identifier">pw</span>.<span class="ruby-identifier">uid</span>
|
565
|
-
296: <span class="ruby-identifier">gid</span> = <span class="ruby-identifier">pw</span>.<span class="ruby-identifier">gid</span>
|
566
|
-
297: <span class="ruby-keyword kw">else</span>
|
567
|
-
298: <span class="ruby-identifier">pw</span> = <span class="ruby-constant">Etc</span>.<span class="ruby-identifier">getpwuid</span>(<span class="ruby-identifier">user</span>)
|
568
|
-
299: <span class="ruby-identifier">username</span> = <span class="ruby-identifier">pw</span>.<span class="ruby-identifier">name</span>
|
569
|
-
300: <span class="ruby-identifier">uid</span> = <span class="ruby-identifier">user</span>
|
570
|
-
301: <span class="ruby-identifier">gid</span> = <span class="ruby-identifier">pw</span>.<span class="ruby-identifier">gid</span>
|
571
|
-
302: <span class="ruby-keyword kw">end</span>
|
572
|
-
303: <span class="ruby-keyword kw">rescue</span>
|
573
|
-
304: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
574
|
-
305: <span class="ruby-keyword kw">end</span>
|
575
|
-
306: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uid</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
576
|
-
307: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
577
|
-
308: <span class="ruby-keyword kw">else</span>
|
578
|
-
309: <span class="ruby-comment cmt"># Some systems are broken. initgroups can fail because of</span>
|
579
|
-
310: <span class="ruby-comment cmt"># all kinds of stupid reasons. So we ignore any errors</span>
|
580
|
-
311: <span class="ruby-comment cmt"># raised by initgroups.</span>
|
581
|
-
312: <span class="ruby-keyword kw">begin</span>
|
582
|
-
313: <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>)
|
583
|
-
314: <span class="ruby-keyword kw">rescue</span>
|
584
|
-
315: <span class="ruby-keyword kw">end</span>
|
585
|
-
316: <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>)
|
586
|
-
317: <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>)
|
587
|
-
318: <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>
|
588
|
-
319: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
589
|
-
320: <span class="ruby-keyword kw">end</span>
|
590
|
-
321: <span class="ruby-keyword kw">end</span>
|
591
|
-
</pre>
|
592
|
-
</div>
|
593
|
-
</div>
|
594
|
-
</div>
|
595
|
-
<div class="method">
|
596
|
-
<div class="title">
|
597
|
-
<a name="M000085"></a><b>unmarshal_and_raise_errors</b>(channel, app_type = "rails")
|
598
|
-
</div>
|
599
|
-
<div class="description">
|
600
|
-
<p>
|
601
|
-
Receive status information that was sent to <tt>channel</tt> by <a
|
602
|
-
href="Utils.html#M000084">report_app_init_status</a>. If an error occured
|
603
|
-
according to the received information, then an appropriate exception will
|
604
|
-
be raised.
|
605
|
-
</p>
|
606
|
-
<p>
|
607
|
-
Raises:
|
608
|
-
</p>
|
609
|
-
<ul>
|
610
|
-
<li><a href="AppInitError.html">AppInitError</a>
|
611
|
-
|
612
|
-
</li>
|
613
|
-
<li>IOError, SystemCallError, SocketError
|
614
|
-
|
615
|
-
</li>
|
616
|
-
</ul>
|
617
|
-
</div>
|
618
|
-
<div class="sourcecode">
|
619
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000085_source')" id="l_M000085_source">show source</a> ]</p>
|
620
|
-
<div id="M000085_source" class="dyn-source">
|
621
|
-
<pre>
|
622
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 253</span>
|
623
|
-
253: <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">app_type</span> = <span class="ruby-value str">"rails"</span>)
|
624
|
-
254: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">read</span>
|
625
|
-
255: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
|
626
|
-
256: <span class="ruby-identifier">raise</span> <span class="ruby-constant">EOFError</span>, <span class="ruby-value str">"Unexpected end-of-file detected."</span>
|
627
|
-
257: <span class="ruby-keyword kw">end</span>
|
628
|
-
258: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]
|
629
|
-
259: <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>
|
630
|
-
260: <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>)
|
631
|
-
261: <span class="ruby-identifier">stderr</span> = <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">read_scalar</span>
|
632
|
-
262: <span class="ruby-comment cmt">#print_exception(self.class.to_s, child_exception)</span>
|
633
|
-
263: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AppInitError</span>.<span class="ruby-identifier">new</span>(
|
634
|
-
264: <span class="ruby-node">"Application '#{@app_root}' raised an exception: "</span> <span class="ruby-operator"><<</span>
|
635
|
-
265: <span class="ruby-node">"#{child_exception.class} (#{child_exception.message})"</span>,
|
636
|
-
266: <span class="ruby-identifier">child_exception</span>,
|
637
|
-
267: <span class="ruby-identifier">app_type</span>,
|
638
|
-
268: <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>)
|
639
|
-
269: <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>
|
640
|
-
270: <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>)
|
641
|
-
271: <span class="ruby-identifier">stderr</span> = <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">read_scalar</span>
|
642
|
-
272: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AppInitError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"Application '#{@app_root}' exited during startup"</span>,
|
643
|
-
273: <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>)
|
644
|
-
274: <span class="ruby-keyword kw">end</span>
|
645
|
-
275: <span class="ruby-keyword kw">end</span>
|
646
|
-
</pre>
|
647
|
-
</div>
|
648
|
-
</div>
|
649
|
-
</div>
|
650
|
-
<div class="method">
|
651
|
-
<div class="title">
|
652
|
-
<a name="M000081"></a><b>unmarshal_exception</b>(data)
|
653
|
-
</div>
|
654
|
-
<div class="sourcecode">
|
655
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000081_source')" id="l_M000081_source">show source</a> ]</p>
|
656
|
-
<div id="M000081_source" class="dyn-source">
|
657
|
-
<pre>
|
658
|
-
<span class="ruby-comment cmt"># File lib/phusion_passenger/utils.rb, line 126</span>
|
659
|
-
126: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unmarshal_exception</span>(<span class="ruby-identifier">data</span>)
|
660
|
-
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>)
|
661
|
-
128: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:is_initialization_error</span>]
|
662
|
-
129: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:child_exception</span>]
|
663
|
-
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>])
|
664
|
-
131: <span class="ruby-keyword kw">else</span>
|
665
|
-
132: <span class="ruby-identifier">child_exception</span> = <span class="ruby-keyword kw">nil</span>
|
666
|
-
133: <span class="ruby-keyword kw">end</span>
|
667
|
-
134:
|
668
|
-
135: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:class</span>]
|
669
|
-
136: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">AppInitError</span>.<span class="ruby-identifier">to_s</span>
|
670
|
-
137: <span class="ruby-identifier">exception_class</span> = <span class="ruby-constant">AppInitError</span>
|
671
|
-
138: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">FrameworkInitError</span>.<span class="ruby-identifier">to_s</span>
|
672
|
-
139: <span class="ruby-identifier">exception_class</span> = <span class="ruby-constant">FrameworkInitError</span>
|
673
|
-
140: <span class="ruby-keyword kw">else</span>
|
674
|
-
141: <span class="ruby-identifier">exception_class</span> = <span class="ruby-constant">InitializationError</span>
|
675
|
-
142: <span class="ruby-keyword kw">end</span>
|
676
|
-
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>)
|
677
|
-
144: <span class="ruby-keyword kw">else</span>
|
678
|
-
145: <span class="ruby-keyword kw">begin</span>
|
679
|
-
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>])
|
680
|
-
147: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-constant">TypeError</span>
|
681
|
-
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>])
|
682
|
-
149: <span class="ruby-keyword kw">end</span>
|
683
|
-
150: <span class="ruby-keyword kw">end</span>
|
684
|
-
151: <span class="ruby-keyword kw">end</span>
|
685
|
-
</pre>
|
686
|
-
</div>
|
687
|
-
</div>
|
688
|
-
</div>
|
689
|
-
</div>
|
690
|
-
|
691
|
-
</div>
|
692
|
-
|
693
|
-
</body>
|
694
|
-
</html>
|