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