mlanett-daemons 1.0.13 → 1.1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +12 -2
- data/LICENSE +1 -8
- data/README-mlanett.rdoc +8 -0
- data/{README → README.rdoc} +6 -15
- data/Releases +84 -9
- data/TODO +1 -5
- data/daemons.gemspec +1 -0
- data/examples/call/call.rb +1 -0
- data/examples/daemonize/daemonize.rb +10 -3
- data/examples/run/ctrl_hanging.rb +19 -0
- data/examples/run/ctrl_monitor_multiple.rb +18 -0
- data/examples/run/ctrl_normal.rb +0 -1
- data/examples/run/ctrl_proc.rb.output +20 -0
- data/examples/run/ctrl_proc_rand.rb +23 -0
- data/examples/run/ctrl_slowstop.rb +16 -0
- data/examples/run/myserver_crashing.rb +2 -2
- data/examples/run/myserver_hanging.rb +21 -0
- data/examples/run/myserver_slowstop.rb +21 -0
- data/lib/daemons.rb +38 -10
- data/lib/daemons/application.rb +131 -26
- data/lib/daemons/application_group.rb +58 -10
- data/lib/daemons/change_privilege.rb +19 -0
- data/lib/daemons/cmdline.rb +10 -6
- data/lib/daemons/controller.rb +5 -2
- data/lib/daemons/daemonize.rb +64 -150
- data/lib/daemons/etc_extension.rb +12 -0
- data/lib/daemons/exceptions.rb +3 -0
- data/lib/daemons/monitor.rb +27 -19
- data/lib/daemons/pid.rb +13 -14
- data/lib/daemons/pidfile.rb +14 -7
- data/lib/daemons/pidmem.rb +9 -0
- data/lib/daemons/version.rb +1 -1
- data/spec/pidfile_spec.rb +12 -0
- data/spec/spec_helper.rb +1 -0
- metadata +31 -47
- data/daemons.tmproj +0 -56
- data/examples/run/myserver_crashing.rb.output +0 -30
- data/html/classes/Daemonize.html +0 -497
- data/html/classes/Daemons.html +0 -683
- data/html/classes/Daemons/Application.html +0 -836
- data/html/classes/Daemons/ApplicationGroup.html +0 -508
- data/html/classes/Daemons/CmdException.html +0 -113
- data/html/classes/Daemons/Controller.html +0 -429
- data/html/classes/Daemons/Error.html +0 -113
- data/html/classes/Daemons/Exception.html +0 -111
- data/html/classes/Daemons/Monitor.html +0 -263
- data/html/classes/Daemons/Optparse.html +0 -244
- data/html/classes/Daemons/Pid.html +0 -339
- data/html/classes/Daemons/PidFile.html +0 -441
- data/html/classes/Daemons/PidMem.html +0 -126
- data/html/classes/Daemons/RuntimeException.html +0 -113
- data/html/classes/Daemons/SystemError.html +0 -163
- data/html/created.rid +0 -1
- data/html/files/README.html +0 -377
- data/html/files/Releases.html +0 -342
- data/html/files/TODO.html +0 -121
- data/html/files/lib/daemons/application_group_rb.html +0 -101
- data/html/files/lib/daemons/application_rb.html +0 -110
- data/html/files/lib/daemons/cmdline_rb.html +0 -101
- data/html/files/lib/daemons/controller_rb.html +0 -101
- data/html/files/lib/daemons/daemonize_rb.html +0 -207
- data/html/files/lib/daemons/exceptions_rb.html +0 -101
- data/html/files/lib/daemons/monitor_rb.html +0 -108
- data/html/files/lib/daemons/pid_rb.html +0 -108
- data/html/files/lib/daemons/pidfile_rb.html +0 -108
- data/html/files/lib/daemons/pidmem_rb.html +0 -108
- data/html/files/lib/daemons_rb.html +0 -117
- data/html/fr_class_index.html +0 -41
- data/html/fr_file_index.html +0 -40
- data/html/fr_method_index.html +0 -91
- data/html/index.html +0 -24
- data/html/rdoc-style.css +0 -208
- data/test/call_as_daemon.rb +0 -12
- data/test/tc_main.rb +0 -24
- data/test/test1.rb +0 -19
- data/test/testapp.rb +0 -11
@@ -1,244 +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::Optparse</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::Optparse</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
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
Object
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</div>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div id="contextContent">
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
</div>
|
84
|
-
|
85
|
-
<div id="method-list">
|
86
|
-
<h3 class="section-bar">Methods</h3>
|
87
|
-
|
88
|
-
<div class="name-list">
|
89
|
-
<a href="#M000014">new</a>
|
90
|
-
<a href="#M000015">parse</a>
|
91
|
-
</div>
|
92
|
-
</div>
|
93
|
-
|
94
|
-
</div>
|
95
|
-
|
96
|
-
|
97
|
-
<!-- if includes -->
|
98
|
-
|
99
|
-
<div id="section">
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
<div id="attribute-list">
|
106
|
-
<h3 class="section-bar">Attributes</h3>
|
107
|
-
|
108
|
-
<div class="name-list">
|
109
|
-
<table>
|
110
|
-
<tr class="top-aligned-row context-row">
|
111
|
-
<td class="context-item-name">usage</td>
|
112
|
-
<td class="context-item-value"> [R] </td>
|
113
|
-
<td class="context-item-desc"></td>
|
114
|
-
</tr>
|
115
|
-
</table>
|
116
|
-
</div>
|
117
|
-
</div>
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
<!-- if method_list -->
|
122
|
-
<div id="methods">
|
123
|
-
<h3 class="section-bar">Public Class methods</h3>
|
124
|
-
|
125
|
-
<div id="method-M000014" class="method-detail">
|
126
|
-
<a name="M000014"></a>
|
127
|
-
|
128
|
-
<div class="method-heading">
|
129
|
-
<a href="#M000014" class="method-signature">
|
130
|
-
<span class="method-name">new</span><span class="method-args">(controller)</span>
|
131
|
-
</a>
|
132
|
-
</div>
|
133
|
-
|
134
|
-
<div class="method-description">
|
135
|
-
<p><a class="source-toggle" href="#"
|
136
|
-
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
137
|
-
<div class="method-source-code" id="M000014-source">
|
138
|
-
<pre>
|
139
|
-
<span class="ruby-comment cmt"># File lib/daemons/cmdline.rb, line 8</span>
|
140
|
-
8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">controller</span>)
|
141
|
-
9: <span class="ruby-ivar">@controller</span> = <span class="ruby-identifier">controller</span>
|
142
|
-
10: <span class="ruby-ivar">@options</span> = {}
|
143
|
-
11:
|
144
|
-
12: <span class="ruby-ivar">@opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
|
145
|
-
13: <span class="ruby-comment cmt">#opts.banner = "Usage: example.rb [options]"</span>
|
146
|
-
14: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-value str">""</span>
|
147
|
-
15:
|
148
|
-
16: <span class="ruby-comment cmt"># Boolean switch.</span>
|
149
|
-
17: <span class="ruby-comment cmt"># opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|</span>
|
150
|
-
18: <span class="ruby-comment cmt"># @options[:verbose] = v</span>
|
151
|
-
19: <span class="ruby-comment cmt"># end</span>
|
152
|
-
20:
|
153
|
-
21: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-t"</span>, <span class="ruby-value str">"--ontop"</span>, <span class="ruby-value str">"Stay on top (does not daemonize)"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
|
154
|
-
22: <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:ontop</span>] = <span class="ruby-identifier">t</span>
|
155
|
-
23: <span class="ruby-keyword kw">end</span>
|
156
|
-
24:
|
157
|
-
25: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-f"</span>, <span class="ruby-value str">"--force"</span>, <span class="ruby-value str">"Force operation"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
|
158
|
-
26: <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:force</span>] = <span class="ruby-identifier">t</span>
|
159
|
-
27: <span class="ruby-keyword kw">end</span>
|
160
|
-
28:
|
161
|
-
29: <span class="ruby-comment cmt">#opts.separator ""</span>
|
162
|
-
30: <span class="ruby-comment cmt">#opts.separator "Specific options:"</span>
|
163
|
-
31:
|
164
|
-
32:
|
165
|
-
33: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">""</span>
|
166
|
-
34: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">"Common options:"</span>
|
167
|
-
35:
|
168
|
-
36: <span class="ruby-comment cmt"># No argument, shows at tail. This will print an options summary.</span>
|
169
|
-
37: <span class="ruby-comment cmt"># Try it and see!</span>
|
170
|
-
38: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>(<span class="ruby-value str">"-h"</span>, <span class="ruby-value str">"--help"</span>, <span class="ruby-value str">"Show this message"</span>) <span class="ruby-keyword kw">do</span>
|
171
|
-
39: <span class="ruby-comment cmt">#puts opts</span>
|
172
|
-
40: <span class="ruby-comment cmt">#@usage = </span>
|
173
|
-
41: <span class="ruby-identifier">controller</span>.<span class="ruby-identifier">print_usage</span>()
|
174
|
-
42:
|
175
|
-
43: <span class="ruby-identifier">exit</span>
|
176
|
-
44: <span class="ruby-keyword kw">end</span>
|
177
|
-
45:
|
178
|
-
46: <span class="ruby-comment cmt"># Another typical switch to print the version.</span>
|
179
|
-
47: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>(<span class="ruby-value str">"--version"</span>, <span class="ruby-value str">"Show version"</span>) <span class="ruby-keyword kw">do</span>
|
180
|
-
48: <span class="ruby-identifier">puts</span> <span class="ruby-node">"daemons version #{Daemons::VERSION}"</span>
|
181
|
-
49: <span class="ruby-identifier">exit</span>
|
182
|
-
50: <span class="ruby-keyword kw">end</span>
|
183
|
-
51: <span class="ruby-keyword kw">end</span>
|
184
|
-
52:
|
185
|
-
53: <span class="ruby-keyword kw">begin</span>
|
186
|
-
54: <span class="ruby-ivar">@usage</span> = <span class="ruby-ivar">@opts</span>.<span class="ruby-identifier">to_s</span>
|
187
|
-
55: <span class="ruby-keyword kw">rescue</span> <span class="ruby-operator">::</span><span class="ruby-constant">Exception</span> <span class="ruby-comment cmt"># work around a bug in ruby 1.9</span>
|
188
|
-
56: <span class="ruby-ivar">@usage</span> = <span class="ruby-value str">" -t, --ontop Stay on top (does not daemonize)\n -f, --force Force operation\n\n Common options:\n -h, --help Show this message\n --version Show version\n"</span>
|
189
|
-
57: <span class="ruby-keyword kw">end</span>
|
190
|
-
58: <span class="ruby-keyword kw">end</span>
|
191
|
-
</pre>
|
192
|
-
</div>
|
193
|
-
</div>
|
194
|
-
</div>
|
195
|
-
|
196
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
197
|
-
|
198
|
-
<div id="method-M000015" class="method-detail">
|
199
|
-
<a name="M000015"></a>
|
200
|
-
|
201
|
-
<div class="method-heading">
|
202
|
-
<a href="#M000015" class="method-signature">
|
203
|
-
<span class="method-name">parse</span><span class="method-args">(args)</span>
|
204
|
-
</a>
|
205
|
-
</div>
|
206
|
-
|
207
|
-
<div class="method-description">
|
208
|
-
<p>
|
209
|
-
Return a hash describing the options.
|
210
|
-
</p>
|
211
|
-
<p><a class="source-toggle" href="#"
|
212
|
-
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
213
|
-
<div class="method-source-code" id="M000015-source">
|
214
|
-
<pre>
|
215
|
-
<span class="ruby-comment cmt"># File lib/daemons/cmdline.rb, line 72</span>
|
216
|
-
72: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">args</span>)
|
217
|
-
73: <span class="ruby-comment cmt"># The options specified on the command line will be collected in *options*.</span>
|
218
|
-
74: <span class="ruby-comment cmt"># We set default values here.</span>
|
219
|
-
75: <span class="ruby-comment cmt">#options = {}</span>
|
220
|
-
76:
|
221
|
-
77:
|
222
|
-
78: <span class="ruby-comment cmt">##pp args</span>
|
223
|
-
79: <span class="ruby-ivar">@opts</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">args</span>)
|
224
|
-
80:
|
225
|
-
81: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@options</span>
|
226
|
-
82: <span class="ruby-keyword kw">end</span>
|
227
|
-
</pre>
|
228
|
-
</div>
|
229
|
-
</div>
|
230
|
-
</div>
|
231
|
-
|
232
|
-
|
233
|
-
</div>
|
234
|
-
|
235
|
-
|
236
|
-
</div>
|
237
|
-
|
238
|
-
|
239
|
-
<div id="validator-badges">
|
240
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
241
|
-
</div>
|
242
|
-
|
243
|
-
</body>
|
244
|
-
</html>
|
@@ -1,339 +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::Pid</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::Pid</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/daemons/pid_rb.html">
|
59
|
-
lib/daemons/pid.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
|
-
Object
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</div>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div id="contextContent">
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
</div>
|
84
|
-
|
85
|
-
<div id="method-list">
|
86
|
-
<h3 class="section-bar">Methods</h3>
|
87
|
-
|
88
|
-
<div class="name-list">
|
89
|
-
<a href="#M000012">cleanup</a>
|
90
|
-
<a href="#M000008">dir</a>
|
91
|
-
<a href="#M000013">exist?</a>
|
92
|
-
<a href="#M000009">new</a>
|
93
|
-
<a href="#M000010">pid</a>
|
94
|
-
<a href="#M000011">pid=</a>
|
95
|
-
<a href="#M000007">running?</a>
|
96
|
-
</div>
|
97
|
-
</div>
|
98
|
-
|
99
|
-
</div>
|
100
|
-
|
101
|
-
|
102
|
-
<!-- if includes -->
|
103
|
-
|
104
|
-
<div id="section">
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
<!-- if method_list -->
|
114
|
-
<div id="methods">
|
115
|
-
<h3 class="section-bar">Public Class methods</h3>
|
116
|
-
|
117
|
-
<div id="method-M000008" class="method-detail">
|
118
|
-
<a name="M000008"></a>
|
119
|
-
|
120
|
-
<div class="method-heading">
|
121
|
-
<a href="#M000008" class="method-signature">
|
122
|
-
<span class="method-name">dir</span><span class="method-args">(dir_mode, dir, script)</span>
|
123
|
-
</a>
|
124
|
-
</div>
|
125
|
-
|
126
|
-
<div class="method-description">
|
127
|
-
<p>
|
128
|
-
Returns the directory that should be used to write the <a
|
129
|
-
href="Pid.html#M000010">pid</a> file to depending on the given mode.
|
130
|
-
</p>
|
131
|
-
<p>
|
132
|
-
Some modes may require an additionaly hint, others may determine the
|
133
|
-
directory automatically.
|
134
|
-
</p>
|
135
|
-
<p>
|
136
|
-
If no valid directory is found, returns nil.
|
137
|
-
</p>
|
138
|
-
<p><a class="source-toggle" href="#"
|
139
|
-
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
140
|
-
<div class="method-source-code" id="M000008-source">
|
141
|
-
<pre>
|
142
|
-
<span class="ruby-comment cmt"># File lib/daemons/pid.rb, line 60</span>
|
143
|
-
60: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Pid</span>.<span class="ruby-identifier">dir</span>(<span class="ruby-identifier">dir_mode</span>, <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">script</span>)
|
144
|
-
61: <span class="ruby-comment cmt"># nil script parameter is allowed as long as dir_mode is not :script</span>
|
145
|
-
62: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dir_mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:script</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">script</span>.<span class="ruby-identifier">nil?</span>
|
146
|
-
63:
|
147
|
-
64: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">dir_mode</span>
|
148
|
-
65: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:normal</span>
|
149
|
-
66: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">dir</span>)
|
150
|
-
67: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:script</span>
|
151
|
-
68: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">script</span>),<span class="ruby-identifier">dir</span>))
|
152
|
-
69: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:system</span>
|
153
|
-
70: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">'/var/run'</span>
|
154
|
-
71: <span class="ruby-keyword kw">else</span>
|
155
|
-
72: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"pid file mode '#{dir_mode}' not implemented"</span>)
|
156
|
-
73: <span class="ruby-keyword kw">end</span>
|
157
|
-
74: <span class="ruby-keyword kw">end</span>
|
158
|
-
</pre>
|
159
|
-
</div>
|
160
|
-
</div>
|
161
|
-
</div>
|
162
|
-
|
163
|
-
<div id="method-M000009" class="method-detail">
|
164
|
-
<a name="M000009"></a>
|
165
|
-
|
166
|
-
<div class="method-heading">
|
167
|
-
<a href="#M000009" class="method-signature">
|
168
|
-
<span class="method-name">new</span><span class="method-args">()</span>
|
169
|
-
</a>
|
170
|
-
</div>
|
171
|
-
|
172
|
-
<div class="method-description">
|
173
|
-
<p>
|
174
|
-
Initialization method
|
175
|
-
</p>
|
176
|
-
<p><a class="source-toggle" href="#"
|
177
|
-
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
178
|
-
<div class="method-source-code" id="M000009-source">
|
179
|
-
<pre>
|
180
|
-
<span class="ruby-comment cmt"># File lib/daemons/pid.rb, line 77</span>
|
181
|
-
77: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
|
182
|
-
78: <span class="ruby-keyword kw">end</span>
|
183
|
-
</pre>
|
184
|
-
</div>
|
185
|
-
</div>
|
186
|
-
</div>
|
187
|
-
|
188
|
-
<div id="method-M000007" class="method-detail">
|
189
|
-
<a name="M000007"></a>
|
190
|
-
|
191
|
-
<div class="method-heading">
|
192
|
-
<a href="#M000007" class="method-signature">
|
193
|
-
<span class="method-name">running?</span><span class="method-args">(pid)</span>
|
194
|
-
</a>
|
195
|
-
</div>
|
196
|
-
|
197
|
-
<div class="method-description">
|
198
|
-
<p><a class="source-toggle" href="#"
|
199
|
-
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
200
|
-
<div class="method-source-code" id="M000007-source">
|
201
|
-
<pre>
|
202
|
-
<span class="ruby-comment cmt"># File lib/daemons/pid.rb, line 8</span>
|
203
|
-
8: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Pid</span>.<span class="ruby-identifier">running?</span>(<span class="ruby-identifier">pid</span>)
|
204
|
-
9: <span class="ruby-comment cmt"># Check if process is in existence</span>
|
205
|
-
10: <span class="ruby-comment cmt"># The simplest way to do this is to send signal '0'</span>
|
206
|
-
11: <span class="ruby-comment cmt"># (which is a single system call) that doesn't actually</span>
|
207
|
-
12: <span class="ruby-comment cmt"># send a signal</span>
|
208
|
-
13: <span class="ruby-keyword kw">begin</span>
|
209
|
-
14: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">pid</span>)
|
210
|
-
15: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
211
|
-
16: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ESRCH</span>
|
212
|
-
17: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
213
|
-
18: <span class="ruby-keyword kw">rescue</span> <span class="ruby-operator">::</span><span class="ruby-constant">Exception</span> <span class="ruby-comment cmt"># for example on EPERM (process exists but does not belong to us)</span>
|
214
|
-
19: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
215
|
-
20: <span class="ruby-comment cmt">#rescue Errno::EPERM</span>
|
216
|
-
21: <span class="ruby-comment cmt"># return false</span>
|
217
|
-
22: <span class="ruby-keyword kw">end</span>
|
218
|
-
23: <span class="ruby-keyword kw">end</span>
|
219
|
-
</pre>
|
220
|
-
</div>
|
221
|
-
</div>
|
222
|
-
</div>
|
223
|
-
|
224
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
225
|
-
|
226
|
-
<div id="method-M000012" class="method-detail">
|
227
|
-
<a name="M000012"></a>
|
228
|
-
|
229
|
-
<div class="method-heading">
|
230
|
-
<a href="#M000012" class="method-signature">
|
231
|
-
<span class="method-name">cleanup</span><span class="method-args">()</span>
|
232
|
-
</a>
|
233
|
-
</div>
|
234
|
-
|
235
|
-
<div class="method-description">
|
236
|
-
<p>
|
237
|
-
Cleanup method
|
238
|
-
</p>
|
239
|
-
<p><a class="source-toggle" href="#"
|
240
|
-
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
241
|
-
<div class="method-source-code" id="M000012-source">
|
242
|
-
<pre>
|
243
|
-
<span class="ruby-comment cmt"># File lib/daemons/pid.rb, line 90</span>
|
244
|
-
90: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cleanup</span>
|
245
|
-
91: <span class="ruby-keyword kw">end</span>
|
246
|
-
</pre>
|
247
|
-
</div>
|
248
|
-
</div>
|
249
|
-
</div>
|
250
|
-
|
251
|
-
<div id="method-M000013" class="method-detail">
|
252
|
-
<a name="M000013"></a>
|
253
|
-
|
254
|
-
<div class="method-heading">
|
255
|
-
<a href="#M000013" class="method-signature">
|
256
|
-
<span class="method-name">exist?</span><span class="method-args">()</span>
|
257
|
-
</a>
|
258
|
-
</div>
|
259
|
-
|
260
|
-
<div class="method-description">
|
261
|
-
<p>
|
262
|
-
Exists? method
|
263
|
-
</p>
|
264
|
-
<p><a class="source-toggle" href="#"
|
265
|
-
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
266
|
-
<div class="method-source-code" id="M000013-source">
|
267
|
-
<pre>
|
268
|
-
<span class="ruby-comment cmt"># File lib/daemons/pid.rb, line 94</span>
|
269
|
-
94: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exist?</span>
|
270
|
-
95: <span class="ruby-keyword kw">true</span>
|
271
|
-
96: <span class="ruby-keyword kw">end</span>
|
272
|
-
</pre>
|
273
|
-
</div>
|
274
|
-
</div>
|
275
|
-
</div>
|
276
|
-
|
277
|
-
<div id="method-M000010" class="method-detail">
|
278
|
-
<a name="M000010"></a>
|
279
|
-
|
280
|
-
<div class="method-heading">
|
281
|
-
<a href="#M000010" class="method-signature">
|
282
|
-
<span class="method-name">pid</span><span class="method-args">()</span>
|
283
|
-
</a>
|
284
|
-
</div>
|
285
|
-
|
286
|
-
<div class="method-description">
|
287
|
-
<p>
|
288
|
-
Get method
|
289
|
-
</p>
|
290
|
-
<p><a class="source-toggle" href="#"
|
291
|
-
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
292
|
-
<div class="method-source-code" id="M000010-source">
|
293
|
-
<pre>
|
294
|
-
<span class="ruby-comment cmt"># File lib/daemons/pid.rb, line 82</span>
|
295
|
-
82: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pid</span>
|
296
|
-
83: <span class="ruby-keyword kw">end</span>
|
297
|
-
</pre>
|
298
|
-
</div>
|
299
|
-
</div>
|
300
|
-
</div>
|
301
|
-
|
302
|
-
<div id="method-M000011" class="method-detail">
|
303
|
-
<a name="M000011"></a>
|
304
|
-
|
305
|
-
<div class="method-heading">
|
306
|
-
<a href="#M000011" class="method-signature">
|
307
|
-
<span class="method-name">pid=</span><span class="method-args">(p)</span>
|
308
|
-
</a>
|
309
|
-
</div>
|
310
|
-
|
311
|
-
<div class="method-description">
|
312
|
-
<p>
|
313
|
-
Set method
|
314
|
-
</p>
|
315
|
-
<p><a class="source-toggle" href="#"
|
316
|
-
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
317
|
-
<div class="method-source-code" id="M000011-source">
|
318
|
-
<pre>
|
319
|
-
<span class="ruby-comment cmt"># File lib/daemons/pid.rb, line 86</span>
|
320
|
-
86: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pid=</span>(<span class="ruby-identifier">p</span>)
|
321
|
-
87: <span class="ruby-keyword kw">end</span>
|
322
|
-
</pre>
|
323
|
-
</div>
|
324
|
-
</div>
|
325
|
-
</div>
|
326
|
-
|
327
|
-
|
328
|
-
</div>
|
329
|
-
|
330
|
-
|
331
|
-
</div>
|
332
|
-
|
333
|
-
|
334
|
-
<div id="validator-badges">
|
335
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
336
|
-
</div>
|
337
|
-
|
338
|
-
</body>
|
339
|
-
</html>
|