thin 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of thin might be problematic. Click here for more details.

Files changed (91) hide show
  1. data/COPYING +18 -0
  2. data/README +32 -45
  3. data/Rakefile +66 -23
  4. data/bin/thin +76 -45
  5. data/doc/benchmarks.txt +64 -249
  6. data/doc/rdoc/created.rid +1 -1
  7. data/doc/rdoc/files/README.html +37 -100
  8. data/doc/rdoc/rdoc-style.css +5 -0
  9. data/example/config.ru +9 -0
  10. data/ext/thin_parser/common.rl +54 -0
  11. data/ext/thin_parser/ext_help.h +14 -0
  12. data/ext/thin_parser/extconf.rb +6 -0
  13. data/ext/thin_parser/parser.c +1199 -0
  14. data/ext/thin_parser/parser.h +49 -0
  15. data/ext/thin_parser/parser.rl +143 -0
  16. data/ext/thin_parser/thin.c +424 -0
  17. data/lib/rack/adapter/rails.rb +136 -0
  18. data/lib/rack/handler/thin.rb +13 -0
  19. data/lib/thin.rb +28 -12
  20. data/lib/thin/connection.rb +47 -0
  21. data/lib/thin/daemonizing.rb +5 -1
  22. data/lib/thin/headers.rb +3 -2
  23. data/lib/thin/logging.rb +6 -13
  24. data/lib/thin/request.rb +53 -133
  25. data/lib/thin/response.rb +21 -25
  26. data/lib/thin/server.rb +30 -94
  27. data/lib/thin/version.rb +2 -2
  28. data/lib/thin_parser.bundle +0 -0
  29. data/spec/daemonizing_spec.rb +94 -0
  30. data/spec/headers_spec.rb +35 -0
  31. data/spec/request_spec.rb +258 -0
  32. data/spec/response_spec.rb +40 -0
  33. data/spec/server_spec.rb +75 -0
  34. data/spec/spec_helper.rb +126 -0
  35. metadata +79 -99
  36. data/bin/thin_cluster +0 -53
  37. data/doc/rdoc/classes/Kernel.html +0 -182
  38. data/doc/rdoc/classes/Process.html +0 -175
  39. data/doc/rdoc/classes/Thin.html +0 -184
  40. data/doc/rdoc/classes/Thin/CGIWrapper.html +0 -438
  41. data/doc/rdoc/classes/Thin/Cluster.html +0 -392
  42. data/doc/rdoc/classes/Thin/Command.html +0 -221
  43. data/doc/rdoc/classes/Thin/CommandError.html +0 -154
  44. data/doc/rdoc/classes/Thin/Commands.html +0 -145
  45. data/doc/rdoc/classes/Thin/Daemonizable.html +0 -250
  46. data/doc/rdoc/classes/Thin/Daemonizable/ClassMethods.html +0 -203
  47. data/doc/rdoc/classes/Thin/DirHandler.html +0 -250
  48. data/doc/rdoc/classes/Thin/Handler.html +0 -195
  49. data/doc/rdoc/classes/Thin/Headers.html +0 -244
  50. data/doc/rdoc/classes/Thin/InvalidRequest.html +0 -150
  51. data/doc/rdoc/classes/Thin/Logging.html +0 -214
  52. data/doc/rdoc/classes/Thin/RailsHandler.html +0 -234
  53. data/doc/rdoc/classes/Thin/RailsServer.html +0 -175
  54. data/doc/rdoc/classes/Thin/Request.html +0 -379
  55. data/doc/rdoc/classes/Thin/Response.html +0 -311
  56. data/doc/rdoc/classes/Thin/Server.html +0 -381
  57. data/doc/rdoc/files/bin/thin.html +0 -188
  58. data/doc/rdoc/files/bin/thin_cluster.html +0 -175
  59. data/doc/rdoc/files/lib/thin/cgi_rb.html +0 -263
  60. data/doc/rdoc/files/lib/thin/cluster_rb.html +0 -263
  61. data/doc/rdoc/files/lib/thin/command_rb.html +0 -263
  62. data/doc/rdoc/files/lib/thin/consts_rb.html +0 -263
  63. data/doc/rdoc/files/lib/thin/daemonizing_rb.html +0 -263
  64. data/doc/rdoc/files/lib/thin/handler_rb.html +0 -263
  65. data/doc/rdoc/files/lib/thin/headers_rb.html +0 -263
  66. data/doc/rdoc/files/lib/thin/logging_rb.html +0 -263
  67. data/doc/rdoc/files/lib/thin/mime_types_rb.html +0 -263
  68. data/doc/rdoc/files/lib/thin/rails_rb.html +0 -263
  69. data/doc/rdoc/files/lib/thin/recipes_rb.html +0 -171
  70. data/doc/rdoc/files/lib/thin/request_rb.html +0 -171
  71. data/doc/rdoc/files/lib/thin/response_rb.html +0 -171
  72. data/doc/rdoc/files/lib/thin/server_rb.html +0 -171
  73. data/doc/rdoc/files/lib/thin/statuses_rb.html +0 -171
  74. data/doc/rdoc/files/lib/thin/version_rb.html +0 -171
  75. data/lib/thin/cgi.rb +0 -159
  76. data/lib/thin/cluster.rb +0 -147
  77. data/lib/thin/command.rb +0 -49
  78. data/lib/thin/commands/cluster/base.rb +0 -24
  79. data/lib/thin/commands/cluster/config.rb +0 -36
  80. data/lib/thin/commands/cluster/restart.rb +0 -35
  81. data/lib/thin/commands/cluster/start.rb +0 -40
  82. data/lib/thin/commands/cluster/stop.rb +0 -28
  83. data/lib/thin/commands/server/base.rb +0 -7
  84. data/lib/thin/commands/server/start.rb +0 -33
  85. data/lib/thin/commands/server/stop.rb +0 -29
  86. data/lib/thin/consts.rb +0 -37
  87. data/lib/thin/handler.rb +0 -57
  88. data/lib/thin/mime_types.rb +0 -619
  89. data/lib/thin/rails.rb +0 -44
  90. data/lib/thin/recipes.rb +0 -36
  91. data/lib/transat/parser.rb +0 -247
@@ -1,438 +0,0 @@
1
-
2
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
- <html>
4
- <head>
5
- <title>
6
- thin &raquo; Class: Thin::CGIWrapper
7
- </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
- <script language="JavaScript" type="text/javascript">
11
- // <![CDATA[
12
-
13
- function toggleSource( id )
14
- {
15
- var elem
16
- var link
17
-
18
- if( document.getElementById )
19
- {
20
- elem = document.getElementById( id )
21
- link = document.getElementById( "l_" + id )
22
- }
23
- else if ( document.all )
24
- {
25
- elem = eval( "document.all." + id )
26
- link = eval( "document.all.l_" + id )
27
- }
28
- else
29
- return false;
30
-
31
- if( elem.style.display == "block" )
32
- {
33
- elem.style.display = "none"
34
- link.innerHTML = "show source"
35
- }
36
- else
37
- {
38
- elem.style.display = "block"
39
- link.innerHTML = "hide source"
40
- }
41
- }
42
-
43
- function openCode( url )
44
- {
45
- window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
46
- }
47
- // ]]>
48
- </script>
49
- </head>
50
- <body>
51
- <ul id="menu">
52
- <li><a href="/thin/">home</a></li>
53
- <li><a href="/thin/doc/">doc</a></li>
54
- <li><a href="/thin/trac.fcgi/timeline">timeline</a></li>
55
- <li><a href="/thin/trac.fcgi/browser">code</a></li>
56
- <li><a href="/thin/trac.fcgi/report">tickets</a></li>
57
- <li><a href="/thin/trac.fcgi/newticket">new ticket</a></li>
58
- </ul>
59
- <div id="sidebar">
60
- <h2>Files</h2>
61
- <ul class="list">
62
- <li><a href="../../files/README.html" value="File: README">README</a></li>
63
- <li><a href="../../files/lib/thin/cgi_rb.html" value="File: cgi.rb">lib/thin/cgi.rb</a></li>
64
- <li><a href="../../files/lib/thin/cluster_rb.html" value="File: cluster.rb">lib/thin/cluster.rb</a></li>
65
- <li><a href="../../files/lib/thin/command_rb.html" value="File: command.rb">lib/thin/command.rb</a></li>
66
- <li><a href="../../files/lib/thin/consts_rb.html" value="File: consts.rb">lib/thin/consts.rb</a></li>
67
- <li><a href="../../files/lib/thin/daemonizing_rb.html" value="File: daemonizing.rb">lib/thin/daemonizing.rb</a></li>
68
- <li><a href="../../files/lib/thin/handler_rb.html" value="File: handler.rb">lib/thin/handler.rb</a></li>
69
- <li><a href="../../files/lib/thin/headers_rb.html" value="File: headers.rb">lib/thin/headers.rb</a></li>
70
- <li><a href="../../files/lib/thin/logging_rb.html" value="File: logging.rb">lib/thin/logging.rb</a></li>
71
- <li><a href="../../files/lib/thin/mime_types_rb.html" value="File: mime_types.rb">lib/thin/mime_types.rb</a></li>
72
- <li><a href="../../files/lib/thin/rails_rb.html" value="File: rails.rb">lib/thin/rails.rb</a></li>
73
- <li><a href="../../files/lib/thin/recipes_rb.html" value="File: recipes.rb">lib/thin/recipes.rb</a></li>
74
- <li><a href="../../files/lib/thin/request_rb.html" value="File: request.rb">lib/thin/request.rb</a></li>
75
- <li><a href="../../files/lib/thin/response_rb.html" value="File: response.rb">lib/thin/response.rb</a></li>
76
- <li><a href="../../files/lib/thin/server_rb.html" value="File: server.rb">lib/thin/server.rb</a></li>
77
- <li><a href="../../files/lib/thin/statuses_rb.html" value="File: statuses.rb">lib/thin/statuses.rb</a></li>
78
- <li><a href="../../files/lib/thin/version_rb.html" value="File: version.rb">lib/thin/version.rb</a></li>
79
- <li><a href="../../files/bin/thin.html" value="File: thin">bin/thin</a></li>
80
- <li><a href="../../files/bin/thin_cluster.html" value="File: thin_cluster">bin/thin_cluster</a></li>
81
- </ul>
82
-
83
- <h2>Classes</h2>
84
- <ul class="list">
85
- <li><a href="../../classes/Thin.html" title="Module: Thin">Thin</a></li>
86
- <li><a href="../../classes/Thin/Commands.html" title="Module: Thin::Commands">Thin::Commands</a></li>
87
- <li><a href="../../classes/Thin/Daemonizable.html" title="Module: Thin::Daemonizable">Thin::Daemonizable</a></li>
88
- <li><a href="../../classes/Thin/Daemonizable/ClassMethods.html" title="Module: Thin::Daemonizable::ClassMethods">Thin::Daemonizable::ClassMethods</a></li>
89
- <li><a href="../../classes/Thin/VERSION.html" title="Module: Thin::VERSION">Thin::VERSION</a></li>
90
- <li><a href="../../classes/Thin/Logging.html" title="Module: Thin::Logging">Thin::Logging</a></li>
91
- <li><a href="../../classes/Thin/DirHandler.html" title="Class: Thin::DirHandler">Thin::DirHandler</a></li>
92
- <li><a href="../../classes/Thin/InvalidRequest.html" title="Class: Thin::InvalidRequest">Thin::InvalidRequest</a></li>
93
- <li><a href="../../classes/Thin/CGIWrapper.html" title="Class: Thin::CGIWrapper">Thin::CGIWrapper</a></li>
94
- <li><a href="../../classes/Thin/Command.html" title="Class: Thin::Command">Thin::Command</a></li>
95
- <li><a href="../../classes/Thin/Response.html" title="Class: Thin::Response">Thin::Response</a></li>
96
- <li><a href="../../classes/Thin/Headers.html" title="Class: Thin::Headers">Thin::Headers</a></li>
97
- <li><a href="../../classes/Thin/Server.html" title="Class: Thin::Server">Thin::Server</a></li>
98
- <li><a href="../../classes/Thin/CommandError.html" title="Class: Thin::CommandError">Thin::CommandError</a></li>
99
- <li><a href="../../classes/Thin/Request.html" title="Class: Thin::Request">Thin::Request</a></li>
100
- <li><a href="../../classes/Thin/RailsServer.html" title="Class: Thin::RailsServer">Thin::RailsServer</a></li>
101
- <li><a href="../../classes/Thin/Cluster.html" title="Class: Thin::Cluster">Thin::Cluster</a></li>
102
- <li><a href="../../classes/Thin/RailsHandler.html" title="Class: Thin::RailsHandler">Thin::RailsHandler</a></li>
103
- <li><a href="../../classes/Thin/Handler.html" title="Class: Thin::Handler">Thin::Handler</a></li>
104
- <li><a href="../../classes/Process.html" title="Module: Process">Process</a></li>
105
- <li><a href="../../classes/Kernel.html" title="Module: Kernel">Kernel</a></li>
106
- </ul>
107
- </div>
108
- <div id="container">
109
- <div id="header">
110
- <a href="/thin/" title="Home">
111
- <img id="logo" src="../../logo.gif" />
112
- </a>
113
- <h2 id="tag_line">A fast and very simple Ruby web server</h2>
114
- </div>
115
-
116
- <div id="content">
117
- <h2>Class: Thin::CGIWrapper</h2>
118
-
119
-
120
- <div id="Thin::CGIWrapper" class="page_shade">
121
- <div class="page">
122
- <h3>Class Thin::CGIWrapper &lt; <a href="Handler.html">::CGI</a></h3>
123
-
124
- <span class="path">(in files
125
- <a href="../../files/lib/thin/cgi_rb.html">lib/thin/cgi.rb</a>
126
- )</span>
127
-
128
- <p>
129
- Class largely based on Mongrel::CGIWrapper <a
130
- href="http://mongrel.rubyforge.org">mongrel.rubyforge.org</a> by Zed A.
131
- Shaw &lt;zedshaw at zedshaw dot com&gt;
132
- </p>
133
-
134
-
135
-
136
-
137
-
138
- <h2 class="ruled">Methods</h2>
139
- <h4 class="ruled">
140
- <span class="method-type" title="Public Class method">Public Class</span>
141
- <strong><a name="M000014" href="#M000014" title="Permalink to Public Class method: new">new(request, response, *args)</a></strong>
142
- </h4>
143
-
144
- <p>
145
- Takes an HttpRequest and HttpResponse object, plus any additional arguments
146
- normally passed to CGI. These are used internally to create a wrapper
147
- around the real CGI while maintaining Mongrel&#8216;s view of the world.
148
- </p>
149
-
150
- <div class="sourcecode">
151
- <p class="source-link">[ <a href="javascript:toggleSource('M000014_source')" id="l_M000014_source">show source</a> ]</p>
152
- <div id="M000014_source" class="dyn-source">
153
- <pre>
154
- <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 20</span>
155
- 20: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
156
- 21: <span class="ruby-ivar">@request</span> = <span class="ruby-identifier">request</span>
157
- 22: <span class="ruby-ivar">@response</span> = <span class="ruby-identifier">response</span>
158
- 23: <span class="ruby-ivar">@args</span> = <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>
159
- 24: <span class="ruby-ivar">@input</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">body</span>
160
- 25: <span class="ruby-ivar">@head</span> = {}
161
- 26: <span class="ruby-ivar">@out_called</span> = <span class="ruby-keyword kw">false</span>
162
- 27: <span class="ruby-ivar">@default_really_final</span> = <span class="ruby-keyword kw">true</span>
163
- 28: <span class="ruby-keyword kw">super</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
164
- 29: <span class="ruby-keyword kw">end</span>
165
- </pre>
166
- </div>
167
- </div>
168
- <h4 class="ruled">
169
- <span class="method-type" title="Public Instance method">Public Instance</span>
170
- <strong><a name="M000019" href="#M000019" title="Permalink to Public Instance method: args">args()</a></strong>
171
- </h4>
172
-
173
- <p>
174
- Used to wrap the normal <a href="CGIWrapper.html#M000019">args</a> variable
175
- used inside CGI.
176
- </p>
177
-
178
- <div class="sourcecode">
179
- <p class="source-link">[ <a href="javascript:toggleSource('M000019_source')" id="l_M000019_source">show source</a> ]</p>
180
- <div id="M000019_source" class="dyn-source">
181
- <pre>
182
- <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 138</span>
183
- 138: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">args</span>
184
- 139: <span class="ruby-ivar">@args</span>
185
- 140: <span class="ruby-keyword kw">end</span>
186
- </pre>
187
- </div>
188
- </div>
189
- <h4 class="ruled">
190
- <span class="method-type" title="Public Instance method">Public Instance</span>
191
- <strong><a name="M000020" href="#M000020" title="Permalink to Public Instance method: env_table">env_table()</a></strong>
192
- </h4>
193
-
194
- <p>
195
- Used to wrap the normal <a href="CGIWrapper.html#M000020">env_table</a>
196
- variable used inside CGI.
197
- </p>
198
-
199
- <div class="sourcecode">
200
- <p class="source-link">[ <a href="javascript:toggleSource('M000020_source')" id="l_M000020_source">show source</a> ]</p>
201
- <div id="M000020_source" class="dyn-source">
202
- <pre>
203
- <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 143</span>
204
- 143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env_table</span>
205
- 144: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
206
- 145: <span class="ruby-keyword kw">end</span>
207
- </pre>
208
- </div>
209
- </div>
210
- <h4 class="ruled">
211
- <span class="method-type" title="Public Instance method">Public Instance</span>
212
- <strong><a name="M000015" href="#M000015" title="Permalink to Public Instance method: header">header(options = &quot;text/html&quot;)</a></strong>
213
- </h4>
214
-
215
- <p>
216
- The <a href="CGIWrapper.html#M000015">header</a> is typically called to
217
- send back the <a href="CGIWrapper.html#M000015">header</a>. In our case we
218
- collect it into a hash for later usage.
219
- </p>
220
- <p>
221
- nph &#8212; Mostly ignored. It&#8216;ll output the date. connection &#8212;
222
- Completely ignored. Why is CGI doing this? length &#8212; Ignored since
223
- Mongrel figures this <a href="CGIWrapper.html#M000017">out</a> from what
224
- you write to output.
225
- </p>
226
-
227
- <div class="sourcecode">
228
- <p class="source-link">[ <a href="javascript:toggleSource('M000015_source')" id="l_M000015_source">show source</a> ]</p>
229
- <div id="M000015_source" class="dyn-source">
230
- <pre>
231
- <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 38</span>
232
- 38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">header</span>(<span class="ruby-identifier">options</span> = <span class="ruby-value str">&quot;text/html&quot;</span>)
233
- 39: <span class="ruby-comment cmt"># if they pass in a string then just write the Content-Type</span>
234
- 40: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">String</span>
235
- 41: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">options</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Content-Type'</span>]
236
- 42: <span class="ruby-keyword kw">else</span>
237
- 43: <span class="ruby-comment cmt"># convert the given options into what Mongrel wants</span>
238
- 44: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'type'</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;text/html&quot;</span>
239
- 45: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Content-Type'</span>] <span class="ruby-operator">+=</span> <span class="ruby-value str">&quot;; charset=&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'charset'</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-value str">&quot;charset&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'charset'</span>]
240
- 46:
241
- 47: <span class="ruby-comment cmt"># setup date only if they use nph</span>
242
- 48: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Date'</span>] = <span class="ruby-constant">CGI</span><span class="ruby-operator">::</span><span class="ruby-identifier">rfc1123_date</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'nph'</span>]
243
- 49:
244
- 50: <span class="ruby-comment cmt"># setup the server to use the default or what they set</span>
245
- 51: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Server'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'server'</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">env_table</span>[<span class="ruby-value str">'SERVER_SOFTWARE'</span>]
246
- 52:
247
- 53: <span class="ruby-comment cmt"># remaining possible options they can give</span>
248
- 54: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Status'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'status'</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'status'</span>]
249
- 55: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Content-Language'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'language'</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'language'</span>]
250
- 56: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Expires'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'expires'</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'expires'</span>]
251
- 57:
252
- 58: <span class="ruby-comment cmt"># drop the keys we don't want anymore</span>
253
- 59: <span class="ruby-constant">REMOVED_KEYS</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>) }
254
- 60:
255
- 61: <span class="ruby-comment cmt"># finally just convert the rest raw (which puts 'cookie' directly)</span>
256
- 62: <span class="ruby-comment cmt"># 'cookie' is translated later as we write the header out</span>
257
- 63: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@head</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>}
258
- 64: <span class="ruby-keyword kw">end</span>
259
- 65:
260
- 66: <span class="ruby-comment cmt"># doing this fakes out the cgi library to think the headers are empty</span>
261
- 67: <span class="ruby-comment cmt"># we then do the real headers in the out function call later</span>
262
- 68: <span class="ruby-value str">&quot;&quot;</span>
263
- 69: <span class="ruby-keyword kw">end</span>
264
- </pre>
265
- </div>
266
- </div>
267
- <h4 class="ruled">
268
- <span class="method-type" title="Public Instance method">Public Instance</span>
269
- <strong><a name="M000017" href="#M000017" title="Permalink to Public Instance method: out">out(options = &quot;text/html&quot;, really_final=@default_really_final) {||| &quot;&quot;)| ...}</a></strong>
270
- </h4>
271
-
272
- <p>
273
- The dumb thing is people can call <a
274
- href="CGIWrapper.html#M000015">header</a> or this or both and in any order.
275
- So, we just reuse <a href="CGIWrapper.html#M000015">header</a> and then
276
- finalize the HttpResponse the right way. Status is taken from the various
277
- options and converted to what Mongrel needs via the <a
278
- href="CGIWrapper.html#M000018">CGIWrapper.status</a> function.
279
- </p>
280
- <p>
281
- We also prevent Rails from actually doing the final send by adding a second
282
- parameter &quot;really_final&quot;. Only Mongrel calls this after Rails is
283
- done. Since this will break other frameworks, it defaults to a different
284
- setting for rails (false) and (true) for others.
285
- </p>
286
-
287
- <div class="sourcecode">
288
- <p class="source-link">[ <a href="javascript:toggleSource('M000017_source')" id="l_M000017_source">show source</a> ]</p>
289
- <div id="M000017_source" class="dyn-source">
290
- <pre>
291
- <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 105</span>
292
- 105: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">out</span>(<span class="ruby-identifier">options</span> = <span class="ruby-value str">&quot;text/html&quot;</span>, <span class="ruby-identifier">really_final</span>=<span class="ruby-ivar">@default_really_final</span>)
293
- 106: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@out_called</span> <span class="ruby-operator">||</span> <span class="ruby-operator">!</span><span class="ruby-identifier">really_final</span>
294
- 107: <span class="ruby-comment cmt"># don't do it more than once or if it's not the really final call</span>
295
- 108: <span class="ruby-keyword kw">return</span>
296
- 109: <span class="ruby-keyword kw">end</span>
297
- 110:
298
- 111: <span class="ruby-identifier">header</span>(<span class="ruby-identifier">options</span>)
299
- 112:
300
- 113: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">start</span> <span class="ruby-identifier">status</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>, <span class="ruby-identifier">body</span><span class="ruby-operator">|</span>
301
- 114: <span class="ruby-identifier">send_cookies</span>(<span class="ruby-identifier">head</span>)
302
- 115:
303
- 116: <span class="ruby-ivar">@head</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">head</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>}
304
- 117: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">write</span>(<span class="ruby-keyword kw">yield</span> <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;&quot;</span>)
305
- 118: <span class="ruby-keyword kw">end</span>
306
- 119:
307
- 120: <span class="ruby-ivar">@out_called</span> = <span class="ruby-keyword kw">true</span>
308
- 121: <span class="ruby-keyword kw">end</span>
309
- </pre>
310
- </div>
311
- </div>
312
- <h4 class="ruled">
313
- <span class="method-type" title="Public Instance method">Public Instance</span>
314
- <strong><a name="M000016" href="#M000016" title="Permalink to Public Instance method: send_cookies">send_cookies(to)</a></strong>
315
- </h4>
316
-
317
- <p>
318
- Takes any &#8216;cookie&#8217; setting and sends it over the Mongrel <a
319
- href="CGIWrapper.html#M000015">header</a>, then removes the setting from
320
- the options. If cookie is an Array or Hash then it sends those on with
321
- .to_s, otherwise it just calls .to_s on it and hopefully your
322
- &quot;cookie&quot; can write itself correctly.
323
- </p>
324
-
325
- <div class="sourcecode">
326
- <p class="source-link">[ <a href="javascript:toggleSource('M000016_source')" id="l_M000016_source">show source</a> ]</p>
327
- <div id="M000016_source" class="dyn-source">
328
- <pre>
329
- <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 76</span>
330
- 76: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_cookies</span>(<span class="ruby-identifier">to</span>)
331
- 77: <span class="ruby-comment cmt"># convert the cookies based on the myriad of possible ways to set a cookie</span>
332
- 78: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'cookie'</span>]
333
- 79: <span class="ruby-identifier">cookie</span> = <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'cookie'</span>]
334
- 80: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">cookie</span>
335
- 81: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
336
- 82: <span class="ruby-identifier">cookie</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">to</span>[<span class="ruby-value str">'Set-Cookie'</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_s</span> }
337
- 83: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Hash</span>
338
- 84: <span class="ruby-identifier">cookie</span>.<span class="ruby-identifier">each_value</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">to</span>[<span class="ruby-value str">'Set-Cookie'</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_s</span>}
339
- 85: <span class="ruby-keyword kw">else</span>
340
- 86: <span class="ruby-identifier">to</span>[<span class="ruby-value str">'Set-Cookie'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'cookie'</span>].<span class="ruby-identifier">to_s</span>
341
- 87: <span class="ruby-keyword kw">end</span>
342
- 88:
343
- 89: <span class="ruby-ivar">@head</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">'cookie'</span>)
344
- 90: <span class="ruby-keyword kw">end</span>
345
- 91:
346
- 92: <span class="ruby-comment cmt"># @output_cookies seems to never be used, but we'll process it just in case</span>
347
- 93: <span class="ruby-ivar">@output_cookies</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">to</span>[<span class="ruby-value str">'Set-Cookie'</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_s</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@output_cookies</span>
348
- 94: <span class="ruby-keyword kw">end</span>
349
- </pre>
350
- </div>
351
- </div>
352
- <h4 class="ruled">
353
- <span class="method-type" title="Public Instance method">Public Instance</span>
354
- <strong><a name="M000018" href="#M000018" title="Permalink to Public Instance method: status">status()</a></strong>
355
- </h4>
356
-
357
- <p>
358
- Computes the <a href="CGIWrapper.html#M000018">status</a> once, but lazily
359
- so that people who call <a href="CGIWrapper.html#M000015">header</a> twice
360
- don&#8216;t get penalized. Because CGI insists on including the options <a
361
- href="CGIWrapper.html#M000018">status</a> message in the <a
362
- href="CGIWrapper.html#M000018">status</a> we have to do a bit of parsing.
363
- </p>
364
-
365
- <div class="sourcecode">
366
- <p class="source-link">[ <a href="javascript:toggleSource('M000018_source')" id="l_M000018_source">show source</a> ]</p>
367
- <div id="M000018_source" class="dyn-source">
368
- <pre>
369
- <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 126</span>
370
- 126: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">status</span>
371
- 127: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@status</span>
372
- 128: <span class="ruby-identifier">stat</span> = <span class="ruby-ivar">@head</span>[<span class="ruby-value str">&quot;Status&quot;</span>]
373
- 129: <span class="ruby-identifier">stat</span> = <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">' '</span>)[<span class="ruby-value">0</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">stat</span>
374
- 130:
375
- 131: <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">stat</span> <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;200&quot;</span>
376
- 132: <span class="ruby-keyword kw">end</span>
377
- 133:
378
- 134: <span class="ruby-ivar">@status</span>
379
- 135: <span class="ruby-keyword kw">end</span>
380
- </pre>
381
- </div>
382
- </div>
383
- <h4 class="ruled">
384
- <span class="method-type" title="Public Instance method">Public Instance</span>
385
- <strong><a name="M000021" href="#M000021" title="Permalink to Public Instance method: stdinput">stdinput()</a></strong>
386
- </h4>
387
-
388
- <p>
389
- Used to wrap the normal <a href="CGIWrapper.html#M000021">stdinput</a>
390
- variable used inside CGI.
391
- </p>
392
-
393
- <div class="sourcecode">
394
- <p class="source-link">[ <a href="javascript:toggleSource('M000021_source')" id="l_M000021_source">show source</a> ]</p>
395
- <div id="M000021_source" class="dyn-source">
396
- <pre>
397
- <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 148</span>
398
- 148: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdinput</span>
399
- 149: <span class="ruby-ivar">@input</span>
400
- 150: <span class="ruby-keyword kw">end</span>
401
- </pre>
402
- </div>
403
- </div>
404
- <h4 class="ruled">
405
- <span class="method-type" title="Public Instance method">Public Instance</span>
406
- <strong><a name="M000022" href="#M000022" title="Permalink to Public Instance method: stdoutput">stdoutput()</a></strong>
407
- </h4>
408
-
409
- <p>
410
- The <a href="CGIWrapper.html#M000022">stdoutput</a> should be completely
411
- bypassed but we&#8216;ll drop a warning just in case
412
- </p>
413
-
414
- <div class="sourcecode">
415
- <p class="source-link">[ <a href="javascript:toggleSource('M000022_source')" id="l_M000022_source">show source</a> ]</p>
416
- <div id="M000022_source" class="dyn-source">
417
- <pre>
418
- <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 153</span>
419
- 153: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdoutput</span>
420
- 154: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;WARNING: Your program is doing something not expected. Please tell Zed that stdoutput was used and what software you are running. Thanks.&quot;</span>
421
- 155: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span>
422
- 156: <span class="ruby-keyword kw">end</span>
423
- </pre>
424
- </div>
425
- </div>
426
-
427
- </div>
428
- </div>
429
-
430
-
431
- </div>
432
- </div>
433
- <div id="footer">
434
- <hr />
435
- &copy; <a href="http://macournoyer.com">Marc-Andr&eacute; Cournoyer</a>
436
- </div>
437
- </body>
438
- </html>
@@ -1,392 +0,0 @@
1
-
2
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
- <html>
4
- <head>
5
- <title>
6
- thin &raquo; Class: Thin::Cluster
7
- </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
- <script language="JavaScript" type="text/javascript">
11
- // <![CDATA[
12
-
13
- function toggleSource( id )
14
- {
15
- var elem
16
- var link
17
-
18
- if( document.getElementById )
19
- {
20
- elem = document.getElementById( id )
21
- link = document.getElementById( "l_" + id )
22
- }
23
- else if ( document.all )
24
- {
25
- elem = eval( "document.all." + id )
26
- link = eval( "document.all.l_" + id )
27
- }
28
- else
29
- return false;
30
-
31
- if( elem.style.display == "block" )
32
- {
33
- elem.style.display = "none"
34
- link.innerHTML = "show source"
35
- }
36
- else
37
- {
38
- elem.style.display = "block"
39
- link.innerHTML = "hide source"
40
- }
41
- }
42
-
43
- function openCode( url )
44
- {
45
- window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
46
- }
47
- // ]]>
48
- </script>
49
- </head>
50
- <body>
51
- <ul id="menu">
52
- <li><a href="/thin/">home</a></li>
53
- <li><a href="/thin/doc/">doc</a></li>
54
- <li><a href="/thin/trac.fcgi/timeline">timeline</a></li>
55
- <li><a href="/thin/trac.fcgi/browser">code</a></li>
56
- <li><a href="/thin/trac.fcgi/report">tickets</a></li>
57
- <li><a href="/thin/trac.fcgi/newticket">new ticket</a></li>
58
- </ul>
59
- <div id="sidebar">
60
- <h2>Files</h2>
61
- <ul class="list">
62
- <li><a href="../../files/README.html" value="File: README">README</a></li>
63
- <li><a href="../../files/lib/thin/cgi_rb.html" value="File: cgi.rb">lib/thin/cgi.rb</a></li>
64
- <li><a href="../../files/lib/thin/cluster_rb.html" value="File: cluster.rb">lib/thin/cluster.rb</a></li>
65
- <li><a href="../../files/lib/thin/command_rb.html" value="File: command.rb">lib/thin/command.rb</a></li>
66
- <li><a href="../../files/lib/thin/consts_rb.html" value="File: consts.rb">lib/thin/consts.rb</a></li>
67
- <li><a href="../../files/lib/thin/daemonizing_rb.html" value="File: daemonizing.rb">lib/thin/daemonizing.rb</a></li>
68
- <li><a href="../../files/lib/thin/handler_rb.html" value="File: handler.rb">lib/thin/handler.rb</a></li>
69
- <li><a href="../../files/lib/thin/headers_rb.html" value="File: headers.rb">lib/thin/headers.rb</a></li>
70
- <li><a href="../../files/lib/thin/logging_rb.html" value="File: logging.rb">lib/thin/logging.rb</a></li>
71
- <li><a href="../../files/lib/thin/mime_types_rb.html" value="File: mime_types.rb">lib/thin/mime_types.rb</a></li>
72
- <li><a href="../../files/lib/thin/rails_rb.html" value="File: rails.rb">lib/thin/rails.rb</a></li>
73
- <li><a href="../../files/lib/thin/recipes_rb.html" value="File: recipes.rb">lib/thin/recipes.rb</a></li>
74
- <li><a href="../../files/lib/thin/request_rb.html" value="File: request.rb">lib/thin/request.rb</a></li>
75
- <li><a href="../../files/lib/thin/response_rb.html" value="File: response.rb">lib/thin/response.rb</a></li>
76
- <li><a href="../../files/lib/thin/server_rb.html" value="File: server.rb">lib/thin/server.rb</a></li>
77
- <li><a href="../../files/lib/thin/statuses_rb.html" value="File: statuses.rb">lib/thin/statuses.rb</a></li>
78
- <li><a href="../../files/lib/thin/version_rb.html" value="File: version.rb">lib/thin/version.rb</a></li>
79
- <li><a href="../../files/bin/thin.html" value="File: thin">bin/thin</a></li>
80
- <li><a href="../../files/bin/thin_cluster.html" value="File: thin_cluster">bin/thin_cluster</a></li>
81
- </ul>
82
-
83
- <h2>Classes</h2>
84
- <ul class="list">
85
- <li><a href="../../classes/Thin.html" title="Module: Thin">Thin</a></li>
86
- <li><a href="../../classes/Thin/Commands.html" title="Module: Thin::Commands">Thin::Commands</a></li>
87
- <li><a href="../../classes/Thin/Daemonizable.html" title="Module: Thin::Daemonizable">Thin::Daemonizable</a></li>
88
- <li><a href="../../classes/Thin/Daemonizable/ClassMethods.html" title="Module: Thin::Daemonizable::ClassMethods">Thin::Daemonizable::ClassMethods</a></li>
89
- <li><a href="../../classes/Thin/VERSION.html" title="Module: Thin::VERSION">Thin::VERSION</a></li>
90
- <li><a href="../../classes/Thin/Logging.html" title="Module: Thin::Logging">Thin::Logging</a></li>
91
- <li><a href="../../classes/Thin/DirHandler.html" title="Class: Thin::DirHandler">Thin::DirHandler</a></li>
92
- <li><a href="../../classes/Thin/InvalidRequest.html" title="Class: Thin::InvalidRequest">Thin::InvalidRequest</a></li>
93
- <li><a href="../../classes/Thin/CGIWrapper.html" title="Class: Thin::CGIWrapper">Thin::CGIWrapper</a></li>
94
- <li><a href="../../classes/Thin/Command.html" title="Class: Thin::Command">Thin::Command</a></li>
95
- <li><a href="../../classes/Thin/Response.html" title="Class: Thin::Response">Thin::Response</a></li>
96
- <li><a href="../../classes/Thin/Headers.html" title="Class: Thin::Headers">Thin::Headers</a></li>
97
- <li><a href="../../classes/Thin/Server.html" title="Class: Thin::Server">Thin::Server</a></li>
98
- <li><a href="../../classes/Thin/CommandError.html" title="Class: Thin::CommandError">Thin::CommandError</a></li>
99
- <li><a href="../../classes/Thin/Request.html" title="Class: Thin::Request">Thin::Request</a></li>
100
- <li><a href="../../classes/Thin/RailsServer.html" title="Class: Thin::RailsServer">Thin::RailsServer</a></li>
101
- <li><a href="../../classes/Thin/Cluster.html" title="Class: Thin::Cluster">Thin::Cluster</a></li>
102
- <li><a href="../../classes/Thin/RailsHandler.html" title="Class: Thin::RailsHandler">Thin::RailsHandler</a></li>
103
- <li><a href="../../classes/Thin/Handler.html" title="Class: Thin::Handler">Thin::Handler</a></li>
104
- <li><a href="../../classes/Process.html" title="Module: Process">Process</a></li>
105
- <li><a href="../../classes/Kernel.html" title="Module: Kernel">Kernel</a></li>
106
- </ul>
107
- </div>
108
- <div id="container">
109
- <div id="header">
110
- <a href="/thin/" title="Home">
111
- <img id="logo" src="../../logo.gif" />
112
- </a>
113
- <h2 id="tag_line">A fast and very simple Ruby web server</h2>
114
- </div>
115
-
116
- <div id="content">
117
- <h2>Class: Thin::Cluster</h2>
118
-
119
-
120
- <div id="Thin::Cluster" class="page_shade">
121
- <div class="page">
122
- <h3>Class Thin::Cluster &lt; <a href="Server.html">Object</a></h3>
123
-
124
- <span class="path">(in files
125
- <a href="../../files/lib/thin/cluster_rb.html">lib/thin/cluster.rb</a>
126
- )</span>
127
-
128
- <p>
129
- Control a set of servers. Generate <a href="Cluster.html#M000058">start</a>
130
- and <a href="Cluster.html#M000060">stop</a> commands and run them.
131
- </p>
132
-
133
-
134
-
135
-
136
- <h4>Includes</h4>
137
- <ul>
138
- <li><a href="Logging.html">Logging</a></li>
139
- </ul>
140
-
141
- <h2 class="ruled">Methods</h2>
142
- <h4 class="ruled">
143
- <span class="method-type" title="Public Class method">Public Class</span>
144
- <strong><a name="M000057" href="#M000057" title="Permalink to Public Class method: new">new(dir, address, first_port, size)</a></strong>
145
- </h4>
146
-
147
- <p>
148
- Create a <a href="Cluster.html#M000057">new</a> cluster of servers bound to
149
- <tt>host</tt> on ports <tt>first_port</tt> to <tt>first_port + size -
150
- 1</tt>.
151
- </p>
152
-
153
- <div class="sourcecode">
154
- <p class="source-link">[ <a href="javascript:toggleSource('M000057_source')" id="l_M000057_source">show source</a> ]</p>
155
- <div id="M000057_source" class="dyn-source">
156
- <pre>
157
- <span class="ruby-comment cmt"># File lib/thin/cluster.rb, line 17</span>
158
- 17: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-identifier">address</span>, <span class="ruby-identifier">first_port</span>, <span class="ruby-identifier">size</span>)
159
- 18: <span class="ruby-ivar">@address</span> = <span class="ruby-identifier">address</span>
160
- 19: <span class="ruby-ivar">@first_port</span> = <span class="ruby-identifier">first_port</span>
161
- 20: <span class="ruby-ivar">@size</span> = <span class="ruby-identifier">size</span>
162
- 21:
163
- 22: <span class="ruby-ivar">@log_file</span> = <span class="ruby-value str">'thin.log'</span>
164
- 23: <span class="ruby-ivar">@pid_file</span> = <span class="ruby-value str">'thin.pid'</span>
165
- 24:
166
- 25: <span class="ruby-ivar">@timeout</span> = <span class="ruby-value">60</span> <span class="ruby-comment cmt"># sec</span>
167
- 26:
168
- 27: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span> <span class="ruby-identifier">dir</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dir</span>
169
- 28: <span class="ruby-keyword kw">end</span>
170
- </pre>
171
- </div>
172
- </div>
173
- <h4 class="ruled">
174
- <span class="method-type" title="Public Class method">Public Class</span>
175
- <strong><a name="M000056" href="#M000056" title="Permalink to Public Class method: thin=">thin=(value)</a></strong>
176
- </h4>
177
-
178
- <p>
179
- Script to run
180
- </p>
181
-
182
- <div class="sourcecode">
183
- <p class="source-link">[ <a href="javascript:toggleSource('M000056_source')" id="l_M000056_source">show source</a> ]</p>
184
- <div id="M000056_source" class="dyn-source">
185
- <pre>
186
- <span class="ruby-comment cmt"># File lib/thin/cluster.rb, line 10</span>
187
- 10: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">thin=</span>(<span class="ruby-identifier">value</span>)
188
- 11: <span class="ruby-ivar">@@thin</span> = <span class="ruby-identifier">value</span>
189
- 12: <span class="ruby-keyword kw">end</span>
190
- </pre>
191
- </div>
192
- </div>
193
- <h4 class="ruled">
194
- <span class="method-type" title="Public Instance method">Public Instance</span>
195
- <strong><a name="M000063" href="#M000063" title="Permalink to Public Instance method: log_file_for">log_file_for(port)</a></strong>
196
- </h4>
197
-
198
-
199
- <div class="sourcecode">
200
- <p class="source-link">[ <a href="javascript:toggleSource('M000063_source')" id="l_M000063_source">show source</a> ]</p>
201
- <div id="M000063_source" class="dyn-source">
202
- <pre>
203
- <span class="ruby-comment cmt"># File lib/thin/cluster.rb, line 91</span>
204
- 91: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">log_file_for</span>(<span class="ruby-identifier">port</span>)
205
- 92: <span class="ruby-identifier">include_port_number</span> <span class="ruby-ivar">@log_file</span>, <span class="ruby-identifier">port</span>
206
- 93: <span class="ruby-keyword kw">end</span>
207
- </pre>
208
- </div>
209
- </div>
210
- <h4 class="ruled">
211
- <span class="method-type" title="Public Instance method">Public Instance</span>
212
- <strong><a name="M000064" href="#M000064" title="Permalink to Public Instance method: pid_file_for">pid_file_for(port)</a></strong>
213
- </h4>
214
-
215
-
216
- <div class="sourcecode">
217
- <p class="source-link">[ <a href="javascript:toggleSource('M000064_source')" id="l_M000064_source">show source</a> ]</p>
218
- <div id="M000064_source" class="dyn-source">
219
- <pre>
220
- <span class="ruby-comment cmt"># File lib/thin/cluster.rb, line 95</span>
221
- 95: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pid_file_for</span>(<span class="ruby-identifier">port</span>)
222
- 96: <span class="ruby-identifier">include_port_number</span> <span class="ruby-ivar">@pid_file</span>, <span class="ruby-identifier">port</span>
223
- 97: <span class="ruby-keyword kw">end</span>
224
- </pre>
225
- </div>
226
- </div>
227
- <h4 class="ruled">
228
- <span class="method-type" title="Public Instance method">Public Instance</span>
229
- <strong><a name="M000065" href="#M000065" title="Permalink to Public Instance method: pid_for">pid_for(port)</a></strong>
230
- </h4>
231
-
232
-
233
- <div class="sourcecode">
234
- <p class="source-link">[ <a href="javascript:toggleSource('M000065_source')" id="l_M000065_source">show source</a> ]</p>
235
- <div id="M000065_source" class="dyn-source">
236
- <pre>
237
- <span class="ruby-comment cmt"># File lib/thin/cluster.rb, line 99</span>
238
- 99: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pid_for</span>(<span class="ruby-identifier">port</span>)
239
- 100: <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">pid_file_for</span>(<span class="ruby-identifier">port</span>)).<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">to_i</span>
240
- 101: <span class="ruby-keyword kw">end</span>
241
- </pre>
242
- </div>
243
- </div>
244
- <h4 class="ruled">
245
- <span class="method-type" title="Public Instance method">Public Instance</span>
246
- <strong><a name="M000062" href="#M000062" title="Permalink to Public Instance method: restart">restart()</a></strong>
247
- </h4>
248
-
249
- <p>
250
- Restart the servers one at the time. Prevent downtime by making sure only
251
- one is stopped at the time. See <a
252
- href="http://blog.carlmercier.com/2007/09/07/a-better-approach-to-restarting-a-mongrel-cluster">blog.carlmercier.com/2007/09/07/a-better-approach-to-restarting-a-mongrel-cluster</a>/
253
- </p>
254
-
255
- <div class="sourcecode">
256
- <p class="source-link">[ <a href="javascript:toggleSource('M000062_source')" id="l_M000062_source">show source</a> ]</p>
257
- <div id="M000062_source" class="dyn-source">
258
- <pre>
259
- <span class="ruby-comment cmt"># File lib/thin/cluster.rb, line 83</span>
260
- 83: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restart</span>
261
- 84: <span class="ruby-identifier">with_each_instance</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">port</span><span class="ruby-operator">|</span>
262
- 85: <span class="ruby-identifier">stop_on_port</span> <span class="ruby-identifier">port</span>
263
- 86: <span class="ruby-identifier">sleep</span> <span class="ruby-value">0</span><span class="ruby-value">.1</span> <span class="ruby-comment cmt"># Let the OS do his thang</span>
264
- 87: <span class="ruby-identifier">start_on_port</span> <span class="ruby-identifier">port</span>
265
- 88: <span class="ruby-keyword kw">end</span>
266
- 89: <span class="ruby-keyword kw">end</span>
267
- </pre>
268
- </div>
269
- </div>
270
- <h4 class="ruled">
271
- <span class="method-type" title="Public Instance method">Public Instance</span>
272
- <strong><a name="M000058" href="#M000058" title="Permalink to Public Instance method: start">start()</a></strong>
273
- </h4>
274
-
275
- <p>
276
- Start the servers
277
- </p>
278
-
279
- <div class="sourcecode">
280
- <p class="source-link">[ <a href="javascript:toggleSource('M000058_source')" id="l_M000058_source">show source</a> ]</p>
281
- <div id="M000058_source" class="dyn-source">
282
- <pre>
283
- <span class="ruby-comment cmt"># File lib/thin/cluster.rb, line 31</span>
284
- 31: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>
285
- 32: <span class="ruby-identifier">with_each_instance</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">port</span><span class="ruby-operator">|</span>
286
- 33: <span class="ruby-identifier">start_on_port</span> <span class="ruby-identifier">port</span>
287
- 34: <span class="ruby-keyword kw">end</span>
288
- 35: <span class="ruby-keyword kw">end</span>
289
- </pre>
290
- </div>
291
- </div>
292
- <h4 class="ruled">
293
- <span class="method-type" title="Public Instance method">Public Instance</span>
294
- <strong><a name="M000059" href="#M000059" title="Permalink to Public Instance method: start_on_port">start_on_port(port)</a></strong>
295
- </h4>
296
-
297
- <p>
298
- Start the server on a single port
299
- </p>
300
-
301
- <div class="sourcecode">
302
- <p class="source-link">[ <a href="javascript:toggleSource('M000059_source')" id="l_M000059_source">show source</a> ]</p>
303
- <div id="M000059_source" class="dyn-source">
304
- <pre>
305
- <span class="ruby-comment cmt"># File lib/thin/cluster.rb, line 38</span>
306
- 38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start_on_port</span>(<span class="ruby-identifier">port</span>)
307
- 39: <span class="ruby-identifier">logc</span> <span class="ruby-node">&quot;Starting #{address}:#{port} ... &quot;</span>
308
- 40:
309
- 41: <span class="ruby-identifier">run</span> <span class="ruby-identifier">:start</span>, <span class="ruby-identifier">:port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">port</span>,
310
- 42: <span class="ruby-identifier">:address</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@address</span>,
311
- 43: <span class="ruby-identifier">:environment</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@environment</span>,
312
- 44: <span class="ruby-identifier">:daemonize</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
313
- 45: <span class="ruby-identifier">:pid_file</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">pid_file_for</span>(<span class="ruby-identifier">port</span>),
314
- 46: <span class="ruby-identifier">:log_file</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">log_file_for</span>(<span class="ruby-identifier">port</span>),
315
- 47: <span class="ruby-identifier">:user</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@user</span>,
316
- 48: <span class="ruby-identifier">:group</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@group</span>,
317
- 49: <span class="ruby-identifier">:timeout</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@timeout</span>,
318
- 50: <span class="ruby-identifier">:trace</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@trace</span>
319
- 51:
320
- 52: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">wait_until_pid</span>(<span class="ruby-identifier">:exist</span>, <span class="ruby-identifier">port</span>)
321
- 53: <span class="ruby-identifier">log</span> <span class="ruby-node">&quot;started in #{pid_for(port)}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$?</span>.<span class="ruby-identifier">success?</span>
322
- 54: <span class="ruby-keyword kw">else</span>
323
- 55: <span class="ruby-identifier">log</span> <span class="ruby-value str">'failed to start'</span>
324
- 56: <span class="ruby-keyword kw">end</span>
325
- 57: <span class="ruby-keyword kw">end</span>
326
- </pre>
327
- </div>
328
- </div>
329
- <h4 class="ruled">
330
- <span class="method-type" title="Public Instance method">Public Instance</span>
331
- <strong><a name="M000060" href="#M000060" title="Permalink to Public Instance method: stop">stop()</a></strong>
332
- </h4>
333
-
334
- <p>
335
- Stop the servers
336
- </p>
337
-
338
- <div class="sourcecode">
339
- <p class="source-link">[ <a href="javascript:toggleSource('M000060_source')" id="l_M000060_source">show source</a> ]</p>
340
- <div id="M000060_source" class="dyn-source">
341
- <pre>
342
- <span class="ruby-comment cmt"># File lib/thin/cluster.rb, line 60</span>
343
- 60: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop</span>
344
- 61: <span class="ruby-identifier">with_each_instance</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">port</span><span class="ruby-operator">|</span>
345
- 62: <span class="ruby-identifier">stop_on_port</span> <span class="ruby-identifier">port</span>
346
- 63: <span class="ruby-keyword kw">end</span>
347
- 64: <span class="ruby-keyword kw">end</span>
348
- </pre>
349
- </div>
350
- </div>
351
- <h4 class="ruled">
352
- <span class="method-type" title="Public Instance method">Public Instance</span>
353
- <strong><a name="M000061" href="#M000061" title="Permalink to Public Instance method: stop_on_port">stop_on_port(port)</a></strong>
354
- </h4>
355
-
356
- <p>
357
- Stop the server running on <tt>port</tt>
358
- </p>
359
-
360
- <div class="sourcecode">
361
- <p class="source-link">[ <a href="javascript:toggleSource('M000061_source')" id="l_M000061_source">show source</a> ]</p>
362
- <div id="M000061_source" class="dyn-source">
363
- <pre>
364
- <span class="ruby-comment cmt"># File lib/thin/cluster.rb, line 67</span>
365
- 67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop_on_port</span>(<span class="ruby-identifier">port</span>)
366
- 68: <span class="ruby-identifier">logc</span> <span class="ruby-node">&quot;Stopping #{address}:#{port} ... &quot;</span>
367
- 69:
368
- 70: <span class="ruby-identifier">run</span> <span class="ruby-identifier">:stop</span>, <span class="ruby-identifier">:pid_file</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">pid_file_for</span>(<span class="ruby-identifier">port</span>),
369
- 71: <span class="ruby-identifier">:timeout</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@timeout</span>
370
- 72:
371
- 73: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">wait_until_pid</span>(<span class="ruby-operator">!</span><span class="ruby-identifier">:exist</span>, <span class="ruby-identifier">port</span>)
372
- 74: <span class="ruby-identifier">log</span> <span class="ruby-value str">'stopped'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$?</span>.<span class="ruby-identifier">success?</span>
373
- 75: <span class="ruby-keyword kw">else</span>
374
- 76: <span class="ruby-identifier">log</span> <span class="ruby-value str">'failed to stop'</span>
375
- 77: <span class="ruby-keyword kw">end</span>
376
- 78: <span class="ruby-keyword kw">end</span>
377
- </pre>
378
- </div>
379
- </div>
380
-
381
- </div>
382
- </div>
383
-
384
-
385
- </div>
386
- </div>
387
- <div id="footer">
388
- <hr />
389
- &copy; <a href="http://macournoyer.com">Marc-Andr&eacute; Cournoyer</a>
390
- </div>
391
- </body>
392
- </html>