mlanett-daemons 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +17 -0
- data/LICENSE +29 -0
- data/README +223 -0
- data/Rakefile +15 -0
- data/Releases +126 -0
- data/TODO +6 -0
- data/daemons.gemspec +27 -0
- data/daemons.tmproj +56 -0
- data/examples/call/call.rb +56 -0
- data/examples/call/call.rb.log +1 -0
- data/examples/call/call_monitor.rb +55 -0
- data/examples/daemonize/daemonize.rb +20 -0
- data/examples/run/ctrl_crash.rb +17 -0
- data/examples/run/ctrl_exec.rb +16 -0
- data/examples/run/ctrl_exit.rb +15 -0
- data/examples/run/ctrl_keep_pid_files.rb +17 -0
- data/examples/run/ctrl_monitor.rb +16 -0
- data/examples/run/ctrl_multiple.rb +16 -0
- data/examples/run/ctrl_normal.rb +12 -0
- data/examples/run/ctrl_ontop.rb +16 -0
- data/examples/run/ctrl_optionparser.rb +43 -0
- data/examples/run/ctrl_proc.rb +25 -0
- data/examples/run/ctrl_proc.rb.output +101 -0
- data/examples/run/ctrl_proc_multiple.rb +22 -0
- data/examples/run/ctrl_proc_multiple.rb.output +2 -0
- data/examples/run/ctrl_proc_simple.rb +17 -0
- data/examples/run/myserver.rb +12 -0
- data/examples/run/myserver_crashing.rb +14 -0
- data/examples/run/myserver_crashing.rb.output +30 -0
- data/examples/run/myserver_exiting.rb +8 -0
- data/html/classes/Daemonize.html +497 -0
- data/html/classes/Daemons.html +683 -0
- data/html/classes/Daemons/Application.html +836 -0
- data/html/classes/Daemons/ApplicationGroup.html +508 -0
- data/html/classes/Daemons/CmdException.html +113 -0
- data/html/classes/Daemons/Controller.html +429 -0
- data/html/classes/Daemons/Error.html +113 -0
- data/html/classes/Daemons/Exception.html +111 -0
- data/html/classes/Daemons/Monitor.html +263 -0
- data/html/classes/Daemons/Optparse.html +244 -0
- data/html/classes/Daemons/Pid.html +339 -0
- data/html/classes/Daemons/PidFile.html +441 -0
- data/html/classes/Daemons/PidMem.html +126 -0
- data/html/classes/Daemons/RuntimeException.html +113 -0
- data/html/classes/Daemons/SystemError.html +163 -0
- data/html/created.rid +1 -0
- data/html/files/README.html +377 -0
- data/html/files/Releases.html +342 -0
- data/html/files/TODO.html +121 -0
- data/html/files/lib/daemons/application_group_rb.html +101 -0
- data/html/files/lib/daemons/application_rb.html +110 -0
- data/html/files/lib/daemons/cmdline_rb.html +101 -0
- data/html/files/lib/daemons/controller_rb.html +101 -0
- data/html/files/lib/daemons/daemonize_rb.html +207 -0
- data/html/files/lib/daemons/exceptions_rb.html +101 -0
- data/html/files/lib/daemons/monitor_rb.html +108 -0
- data/html/files/lib/daemons/pid_rb.html +108 -0
- data/html/files/lib/daemons/pidfile_rb.html +108 -0
- data/html/files/lib/daemons/pidmem_rb.html +108 -0
- data/html/files/lib/daemons_rb.html +117 -0
- data/html/fr_class_index.html +41 -0
- data/html/fr_file_index.html +40 -0
- data/html/fr_method_index.html +91 -0
- data/html/index.html +24 -0
- data/html/rdoc-style.css +208 -0
- data/lib/daemons.rb +284 -0
- data/lib/daemons/application.rb +376 -0
- data/lib/daemons/application_group.rb +152 -0
- data/lib/daemons/cmdline.rb +117 -0
- data/lib/daemons/controller.rb +137 -0
- data/lib/daemons/daemonize.rb +263 -0
- data/lib/daemons/exceptions.rb +28 -0
- data/lib/daemons/monitor.rb +136 -0
- data/lib/daemons/pid.rb +115 -0
- data/lib/daemons/pidfile.rb +111 -0
- data/lib/daemons/pidmem.rb +10 -0
- data/lib/daemons/version.rb +3 -0
- data/setup.rb +1360 -0
- data/test/call_as_daemon.rb +12 -0
- data/test/tc_main.rb +24 -0
- data/test/test1.rb +19 -0
- data/test/testapp.rb +11 -0
- metadata +170 -0
@@ -0,0 +1,113 @@
|
|
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>
|
@@ -0,0 +1,429 @@
|
|
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>
|
94
|
+
<a href="#M000034">new</a>
|
95
|
+
<a href="#M000032">print_usage</a>
|
96
|
+
<a href="#M000036">run</a>
|
97
|
+
<a href="#M000035">setup_options</a>
|
98
|
+
<a href="#M000037">split_argv</a>
|
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"> [R] </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"> [R] </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"> [R] </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 "--" 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">(&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">&</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">></span> <span class="ruby-identifier">e</span>
|
275
|
+
108: <span class="ruby-identifier">puts</span> <span class="ruby-node">"ERROR: #{e.to_s}"</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">></span> <span class="ruby-identifier">e</span>
|
279
|
+
112: <span class="ruby-identifier">puts</span> <span class="ruby-node">"ERROR: #{e.to_s}"</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">"Usage: #{@app_name} <command> <options> -- <application options>"</span>
|
304
|
+
91: <span class="ruby-identifier">puts</span>
|
305
|
+
92: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"* where <command> is one of:"</span>
|
306
|
+
93: <span class="ruby-identifier">puts</span> <span class="ruby-value str">" start start an instance of the application"</span>
|
307
|
+
94: <span class="ruby-identifier">puts</span> <span class="ruby-value str">" stop stop all instances of the application"</span>
|
308
|
+
95: <span class="ruby-identifier">puts</span> <span class="ruby-value str">" restart stop all instances and restart them afterwards"</span>
|
309
|
+
96: <span class="ruby-identifier">puts</span> <span class="ruby-value str">" run start the application and stay on top"</span>
|
310
|
+
97: <span class="ruby-identifier">puts</span> <span class="ruby-value str">" zap set the application to a stopped state"</span>
|
311
|
+
98: <span class="ruby-identifier">puts</span>
|
312
|
+
99: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"* and where <options> may contain several of the following:"</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">"#{@group.app_name}: no instances running"</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 "ERROR: No command given"; 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">"command '#{@command}' not implemented"</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>
|