mlanett-daemons 1.0.13 → 1.1.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. data/Gemfile.lock +12 -2
  2. data/LICENSE +1 -8
  3. data/README-mlanett.rdoc +8 -0
  4. data/{README → README.rdoc} +6 -15
  5. data/Releases +84 -9
  6. data/TODO +1 -5
  7. data/daemons.gemspec +1 -0
  8. data/examples/call/call.rb +1 -0
  9. data/examples/daemonize/daemonize.rb +10 -3
  10. data/examples/run/ctrl_hanging.rb +19 -0
  11. data/examples/run/ctrl_monitor_multiple.rb +18 -0
  12. data/examples/run/ctrl_normal.rb +0 -1
  13. data/examples/run/ctrl_proc.rb.output +20 -0
  14. data/examples/run/ctrl_proc_rand.rb +23 -0
  15. data/examples/run/ctrl_slowstop.rb +16 -0
  16. data/examples/run/myserver_crashing.rb +2 -2
  17. data/examples/run/myserver_hanging.rb +21 -0
  18. data/examples/run/myserver_slowstop.rb +21 -0
  19. data/lib/daemons.rb +38 -10
  20. data/lib/daemons/application.rb +131 -26
  21. data/lib/daemons/application_group.rb +58 -10
  22. data/lib/daemons/change_privilege.rb +19 -0
  23. data/lib/daemons/cmdline.rb +10 -6
  24. data/lib/daemons/controller.rb +5 -2
  25. data/lib/daemons/daemonize.rb +64 -150
  26. data/lib/daemons/etc_extension.rb +12 -0
  27. data/lib/daemons/exceptions.rb +3 -0
  28. data/lib/daemons/monitor.rb +27 -19
  29. data/lib/daemons/pid.rb +13 -14
  30. data/lib/daemons/pidfile.rb +14 -7
  31. data/lib/daemons/pidmem.rb +9 -0
  32. data/lib/daemons/version.rb +1 -1
  33. data/spec/pidfile_spec.rb +12 -0
  34. data/spec/spec_helper.rb +1 -0
  35. metadata +31 -47
  36. data/daemons.tmproj +0 -56
  37. data/examples/run/myserver_crashing.rb.output +0 -30
  38. data/html/classes/Daemonize.html +0 -497
  39. data/html/classes/Daemons.html +0 -683
  40. data/html/classes/Daemons/Application.html +0 -836
  41. data/html/classes/Daemons/ApplicationGroup.html +0 -508
  42. data/html/classes/Daemons/CmdException.html +0 -113
  43. data/html/classes/Daemons/Controller.html +0 -429
  44. data/html/classes/Daemons/Error.html +0 -113
  45. data/html/classes/Daemons/Exception.html +0 -111
  46. data/html/classes/Daemons/Monitor.html +0 -263
  47. data/html/classes/Daemons/Optparse.html +0 -244
  48. data/html/classes/Daemons/Pid.html +0 -339
  49. data/html/classes/Daemons/PidFile.html +0 -441
  50. data/html/classes/Daemons/PidMem.html +0 -126
  51. data/html/classes/Daemons/RuntimeException.html +0 -113
  52. data/html/classes/Daemons/SystemError.html +0 -163
  53. data/html/created.rid +0 -1
  54. data/html/files/README.html +0 -377
  55. data/html/files/Releases.html +0 -342
  56. data/html/files/TODO.html +0 -121
  57. data/html/files/lib/daemons/application_group_rb.html +0 -101
  58. data/html/files/lib/daemons/application_rb.html +0 -110
  59. data/html/files/lib/daemons/cmdline_rb.html +0 -101
  60. data/html/files/lib/daemons/controller_rb.html +0 -101
  61. data/html/files/lib/daemons/daemonize_rb.html +0 -207
  62. data/html/files/lib/daemons/exceptions_rb.html +0 -101
  63. data/html/files/lib/daemons/monitor_rb.html +0 -108
  64. data/html/files/lib/daemons/pid_rb.html +0 -108
  65. data/html/files/lib/daemons/pidfile_rb.html +0 -108
  66. data/html/files/lib/daemons/pidmem_rb.html +0 -108
  67. data/html/files/lib/daemons_rb.html +0 -117
  68. data/html/fr_class_index.html +0 -41
  69. data/html/fr_file_index.html +0 -40
  70. data/html/fr_method_index.html +0 -91
  71. data/html/index.html +0 -24
  72. data/html/rdoc-style.css +0 -208
  73. data/test/call_as_daemon.rb +0 -12
  74. data/test/tc_main.rb +0 -24
  75. data/test/test1.rb +0 -19
  76. data/test/testapp.rb +0 -11
@@ -1,113 +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
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Daemons::CmdException</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Daemons::CmdException</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/daemons/exceptions_rb.html">
59
- lib/daemons/exceptions.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- <a href="Exception.html">
69
- Exception
70
- </a>
71
- </td>
72
- </tr>
73
- </table>
74
- </div>
75
- <!-- banner header -->
76
-
77
- <div id="bodyContent">
78
-
79
-
80
-
81
- <div id="contextContent">
82
-
83
-
84
-
85
- </div>
86
-
87
-
88
- </div>
89
-
90
-
91
- <!-- if includes -->
92
-
93
- <div id="section">
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
- <!-- if method_list -->
103
-
104
-
105
- </div>
106
-
107
-
108
- <div id="validator-badges">
109
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
110
- </div>
111
-
112
- </body>
113
- </html>
@@ -1,429 +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
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Daemons::Controller</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Daemons::Controller</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/daemons/cmdline_rb.html">
59
- lib/daemons/cmdline.rb
60
- </a>
61
- <br />
62
- <a href="../../files/lib/daemons/controller_rb.html">
63
- lib/daemons/controller.rb
64
- </a>
65
- <br />
66
- </td>
67
- </tr>
68
-
69
- <tr class="top-aligned-row">
70
- <td><strong>Parent:</strong></td>
71
- <td>
72
- Object
73
- </td>
74
- </tr>
75
- </table>
76
- </div>
77
- <!-- banner header -->
78
-
79
- <div id="bodyContent">
80
-
81
-
82
-
83
- <div id="contextContent">
84
-
85
-
86
-
87
- </div>
88
-
89
- <div id="method-list">
90
- <h3 class="section-bar">Methods</h3>
91
-
92
- <div class="name-list">
93
- <a href="#M000033">catch_exceptions</a>&nbsp;&nbsp;
94
- <a href="#M000034">new</a>&nbsp;&nbsp;
95
- <a href="#M000032">print_usage</a>&nbsp;&nbsp;
96
- <a href="#M000036">run</a>&nbsp;&nbsp;
97
- <a href="#M000035">setup_options</a>&nbsp;&nbsp;
98
- <a href="#M000037">split_argv</a>&nbsp;&nbsp;
99
- </div>
100
- </div>
101
-
102
- </div>
103
-
104
-
105
- <!-- if includes -->
106
-
107
- <div id="section">
108
-
109
-
110
- <div id="constants-list">
111
- <h3 class="section-bar">Constants</h3>
112
-
113
- <div class="name-list">
114
- <table summary="Constants">
115
- <tr class="top-aligned-row context-row">
116
- <td class="context-item-name">COMMANDS</td>
117
- <td>=</td>
118
- <td class="context-item-value">[ 'start', 'stop', 'restart', 'run', 'zap', 'status'</td>
119
- </tr>
120
- </table>
121
- </div>
122
- </div>
123
-
124
-
125
-
126
- <div id="attribute-list">
127
- <h3 class="section-bar">Attributes</h3>
128
-
129
- <div class="name-list">
130
- <table>
131
- <tr class="top-aligned-row context-row">
132
- <td class="context-item-name">app_name</td>
133
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
134
- <td class="context-item-desc"></td>
135
- </tr>
136
- <tr class="top-aligned-row context-row">
137
- <td class="context-item-name">group</td>
138
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
139
- <td class="context-item-desc"></td>
140
- </tr>
141
- <tr class="top-aligned-row context-row">
142
- <td class="context-item-name">options</td>
143
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
144
- <td class="context-item-desc"></td>
145
- </tr>
146
- </table>
147
- </div>
148
- </div>
149
-
150
-
151
-
152
- <!-- if method_list -->
153
- <div id="methods">
154
- <h3 class="section-bar">Public Class methods</h3>
155
-
156
- <div id="method-M000034" class="method-detail">
157
- <a name="M000034"></a>
158
-
159
- <div class="method-heading">
160
- <a href="#M000034" class="method-signature">
161
- <span class="method-name">new</span><span class="method-args">(options = {}, argv = [])</span>
162
- </a>
163
- </div>
164
-
165
- <div class="method-description">
166
- <p><a class="source-toggle" href="#"
167
- onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
168
- <div class="method-source-code" id="M000034-source">
169
- <pre>
170
- <span class="ruby-comment cmt"># File lib/daemons/controller.rb, line 21</span>
171
- 21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span> = {}, <span class="ruby-identifier">argv</span> = [])
172
- 22: <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
173
- 23: <span class="ruby-ivar">@argv</span> = <span class="ruby-identifier">argv</span>
174
- 24:
175
- 25: <span class="ruby-comment cmt"># Allow an app_name to be specified. If not specified use the</span>
176
- 26: <span class="ruby-comment cmt"># basename of the script.</span>
177
- 27: <span class="ruby-ivar">@app_name</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:app_name</span>]
178
- 28:
179
- 29: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:script</span>]
180
- 30: <span class="ruby-ivar">@script</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:script</span>])
181
- 31:
182
- 32: <span class="ruby-ivar">@app_name</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">split</span>(<span class="ruby-ivar">@script</span>)[<span class="ruby-value">1</span>]
183
- 33: <span class="ruby-keyword kw">end</span>
184
- 34:
185
- 35: <span class="ruby-ivar">@app_name</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">'unknown_application'</span>
186
- 36:
187
- 37: <span class="ruby-ivar">@command</span>, <span class="ruby-ivar">@controller_part</span>, <span class="ruby-ivar">@app_part</span> = <span class="ruby-constant">Controller</span>.<span class="ruby-identifier">split_argv</span>(<span class="ruby-identifier">argv</span>)
188
- 38:
189
- 39: <span class="ruby-comment cmt">#@options[:dir_mode] ||= :script</span>
190
- 40:
191
- 41: <span class="ruby-ivar">@optparse</span> = <span class="ruby-constant">Optparse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
192
- 42: <span class="ruby-keyword kw">end</span>
193
- </pre>
194
- </div>
195
- </div>
196
- </div>
197
-
198
- <div id="method-M000037" class="method-detail">
199
- <a name="M000037"></a>
200
-
201
- <div class="method-heading">
202
- <a href="#M000037" class="method-signature">
203
- <span class="method-name">split_argv</span><span class="method-args">(argv)</span>
204
- </a>
205
- </div>
206
-
207
- <div class="method-description">
208
- <p>
209
- Split an <em>argv</em> array. <tt>argv</tt> is assumed to be in the
210
- following format:
211
- </p>
212
- <pre>
213
- ['command', 'controller option 1', 'controller option 2', ..., '--', 'app option 1', ...]
214
- </pre>
215
- <p>
216
- <tt>command</tt> must be one of the commands listed in <tt>COMMANDS</tt>
217
- </p>
218
- <p>
219
- <b>Returns</b>: the command as a string, the controller options as an
220
- array, the appliation options as an array
221
- </p>
222
- <p><a class="source-toggle" href="#"
223
- onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
224
- <div class="method-source-code" id="M000037-source">
225
- <pre>
226
- <span class="ruby-comment cmt"># File lib/daemons/controller.rb, line 110</span>
227
- 110: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Controller</span>.<span class="ruby-identifier">split_argv</span>(<span class="ruby-identifier">argv</span>)
228
- 111: <span class="ruby-identifier">argv</span> = <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">dup</span>
229
- 112:
230
- 113: <span class="ruby-identifier">command</span> = <span class="ruby-keyword kw">nil</span>
231
- 114: <span class="ruby-identifier">controller_part</span> = []
232
- 115: <span class="ruby-identifier">app_part</span> = []
233
- 116:
234
- 117: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">COMMANDS</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">argv</span>[<span class="ruby-value">0</span>]
235
- 118: <span class="ruby-identifier">command</span> = <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">shift</span>
236
- 119: <span class="ruby-keyword kw">end</span>
237
- 120:
238
- 121: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">i</span> = <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value str">'--'</span>)
239
- 122: <span class="ruby-comment cmt"># Handle the case where no controller options are given, just</span>
240
- 123: <span class="ruby-comment cmt"># options after &quot;--&quot; as well (i == 0)</span>
241
- 124: <span class="ruby-identifier">controller_part</span> = (<span class="ruby-identifier">i</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> [] <span class="ruby-operator">:</span> <span class="ruby-identifier">argv</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">i</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>])
242
- 125: <span class="ruby-identifier">app_part</span> = <span class="ruby-identifier">argv</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">+</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
243
- 126: <span class="ruby-keyword kw">else</span>
244
- 127: <span class="ruby-identifier">controller_part</span> = <span class="ruby-identifier">argv</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
245
- 128: <span class="ruby-keyword kw">end</span>
246
- 129:
247
- 130: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">command</span>, <span class="ruby-identifier">controller_part</span>, <span class="ruby-identifier">app_part</span>
248
- 131: <span class="ruby-keyword kw">end</span>
249
- </pre>
250
- </div>
251
- </div>
252
- </div>
253
-
254
- <h3 class="section-bar">Public Instance methods</h3>
255
-
256
- <div id="method-M000033" class="method-detail">
257
- <a name="M000033"></a>
258
-
259
- <div class="method-heading">
260
- <a href="#M000033" class="method-signature">
261
- <span class="method-name">catch_exceptions</span><span class="method-args">(&amp;block)</span>
262
- </a>
263
- </div>
264
-
265
- <div class="method-description">
266
- <p><a class="source-toggle" href="#"
267
- onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
268
- <div class="method-source-code" id="M000033-source">
269
- <pre>
270
- <span class="ruby-comment cmt"># File lib/daemons/cmdline.rb, line 104</span>
271
- 104: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">catch_exceptions</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
272
- 105: <span class="ruby-keyword kw">begin</span>
273
- 106: <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>
274
- 107: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">CmdException</span>, <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
275
- 108: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;ERROR: #{e.to_s}&quot;</span>
276
- 109: <span class="ruby-identifier">puts</span>
277
- 110: <span class="ruby-identifier">print_usage</span>()
278
- 111: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">RuntimeException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
279
- 112: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;ERROR: #{e.to_s}&quot;</span>
280
- 113: <span class="ruby-keyword kw">end</span>
281
- 114: <span class="ruby-keyword kw">end</span>
282
- </pre>
283
- </div>
284
- </div>
285
- </div>
286
-
287
- <div id="method-M000032" class="method-detail">
288
- <a name="M000032"></a>
289
-
290
- <div class="method-heading">
291
- <a href="#M000032" class="method-signature">
292
- <span class="method-name">print_usage</span><span class="method-args">()</span>
293
- </a>
294
- </div>
295
-
296
- <div class="method-description">
297
- <p><a class="source-toggle" href="#"
298
- onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
299
- <div class="method-source-code" id="M000032-source">
300
- <pre>
301
- <span class="ruby-comment cmt"># File lib/daemons/cmdline.rb, line 89</span>
302
- 89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print_usage</span>
303
- 90: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Usage: #{@app_name} &lt;command&gt; &lt;options&gt; -- &lt;application options&gt;&quot;</span>
304
- 91: <span class="ruby-identifier">puts</span>
305
- 92: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;* where &lt;command&gt; is one of:&quot;</span>
306
- 93: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot; start start an instance of the application&quot;</span>
307
- 94: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot; stop stop all instances of the application&quot;</span>
308
- 95: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot; restart stop all instances and restart them afterwards&quot;</span>
309
- 96: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot; run start the application and stay on top&quot;</span>
310
- 97: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot; zap set the application to a stopped state&quot;</span>
311
- 98: <span class="ruby-identifier">puts</span>
312
- 99: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;* and where &lt;options&gt; may contain several of the following:&quot;</span>
313
- 100:
314
- 101: <span class="ruby-identifier">puts</span> <span class="ruby-ivar">@optparse</span>.<span class="ruby-identifier">usage</span>
315
- 102: <span class="ruby-keyword kw">end</span>
316
- </pre>
317
- </div>
318
- </div>
319
- </div>
320
-
321
- <div id="method-M000036" class="method-detail">
322
- <a name="M000036"></a>
323
-
324
- <div class="method-heading">
325
- <a href="#M000036" class="method-signature">
326
- <span class="method-name">run</span><span class="method-args">()</span>
327
- </a>
328
- </div>
329
-
330
- <div class="method-description">
331
- <p><a class="source-toggle" href="#"
332
- onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
333
- <div class="method-source-code" id="M000036-source">
334
- <pre>
335
- <span class="ruby-comment cmt"># File lib/daemons/controller.rb, line 54</span>
336
- 54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>
337
- 55: <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">update</span> <span class="ruby-ivar">@optparse</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-ivar">@controller_part</span>).<span class="ruby-identifier">delete_if</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-operator">!</span><span class="ruby-identifier">v</span>}
338
- 56:
339
- 57: <span class="ruby-identifier">setup_options</span>()
340
- 58:
341
- 59: <span class="ruby-comment cmt">#pp @options</span>
342
- 60:
343
- 61: <span class="ruby-ivar">@group</span> = <span class="ruby-constant">ApplicationGroup</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@app_name</span>, <span class="ruby-ivar">@options</span>)
344
- 62: <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">controller_argv</span> = <span class="ruby-ivar">@controller_part</span>
345
- 63: <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">app_argv</span> = <span class="ruby-ivar">@app_part</span>
346
- 64:
347
- 65: <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">setup</span>
348
- 66:
349
- 67: <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@command</span>
350
- 68: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'start'</span>
351
- 69: <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">new_application</span>.<span class="ruby-identifier">start</span>
352
- 70: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'run'</span>
353
- 71: <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:ontop</span>] <span class="ruby-operator">||=</span> <span class="ruby-keyword kw">true</span>
354
- 72: <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">new_application</span>.<span class="ruby-identifier">start</span>
355
- 73: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'stop'</span>
356
- 74: <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">stop_all</span>
357
- 75: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'restart'</span>
358
- 76: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">applications</span>.<span class="ruby-identifier">empty?</span>
359
- 77: <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">stop_all</span>
360
- 78: <span class="ruby-identifier">sleep</span> <span class="ruby-value">1</span>
361
- 79: <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">start_all</span>
362
- 80: <span class="ruby-keyword kw">end</span>
363
- 81: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'zap'</span>
364
- 82: <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">zap_all</span>
365
- 83: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'status'</span>
366
- 84: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">applications</span>.<span class="ruby-identifier">empty?</span>
367
- 85: <span class="ruby-ivar">@group</span>.<span class="ruby-identifier">show_status</span>
368
- 86: <span class="ruby-keyword kw">else</span>
369
- 87: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{@group.app_name}: no instances running&quot;</span>
370
- 88: <span class="ruby-keyword kw">end</span>
371
- 89: <span class="ruby-keyword kw">when</span> <span class="ruby-keyword kw">nil</span>
372
- 90: <span class="ruby-identifier">raise</span> <span class="ruby-constant">CmdException</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'no command given'</span>)
373
- 91: <span class="ruby-comment cmt">#puts &quot;ERROR: No command given&quot;; puts</span>
374
- 92:
375
- 93: <span class="ruby-comment cmt">#print_usage()</span>
376
- 94: <span class="ruby-comment cmt">#raise('usage function not implemented')</span>
377
- 95: <span class="ruby-keyword kw">else</span>
378
- 96: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;command '#{@command}' not implemented&quot;</span>)
379
- 97: <span class="ruby-keyword kw">end</span>
380
- 98: <span class="ruby-keyword kw">end</span>
381
- </pre>
382
- </div>
383
- </div>
384
- </div>
385
-
386
- <div id="method-M000035" class="method-detail">
387
- <a name="M000035"></a>
388
-
389
- <div class="method-heading">
390
- <a href="#M000035" class="method-signature">
391
- <span class="method-name">setup_options</span><span class="method-args">()</span>
392
- </a>
393
- </div>
394
-
395
- <div class="method-description">
396
- <p>
397
- This function is used to do a final update of the options passed to the
398
- application before they are really used.
399
- </p>
400
- <p>
401
- Note that this function should only update <tt>@options</tt> and no other
402
- variables.
403
- </p>
404
- <p><a class="source-toggle" href="#"
405
- onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
406
- <div class="method-source-code" id="M000035-source">
407
- <pre>
408
- <span class="ruby-comment cmt"># File lib/daemons/controller.rb, line 50</span>
409
- 50: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup_options</span>
410
- 51: <span class="ruby-comment cmt">#@options[:ontop] ||= true</span>
411
- 52: <span class="ruby-keyword kw">end</span>
412
- </pre>
413
- </div>
414
- </div>
415
- </div>
416
-
417
-
418
- </div>
419
-
420
-
421
- </div>
422
-
423
-
424
- <div id="validator-badges">
425
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
426
- </div>
427
-
428
- </body>
429
- </html>