pidify 0.1.2-i686-linux → 0.2-i686-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/classes/Pidify.html +137 -47
- data/doc/classes/Pidify.src/M000001.html +1 -1
- data/doc/classes/Pidify.src/M000002.html +1 -1
- data/doc/classes/Pidify.src/M000003.html +2 -2
- data/doc/classes/Pidify.src/M000004.html +3 -3
- data/doc/classes/Pidify.src/M000005.html +10 -6
- data/doc/classes/Pidify.src/M000006.html +12 -4
- data/doc/classes/Pidify.src/M000007.html +10 -4
- data/doc/classes/Pidify.src/M000008.html +11 -5
- data/doc/classes/Pidify.src/M000009.html +5 -17
- data/doc/classes/Pidify.src/M000010.html +27 -0
- data/doc/classes/Pidify.src/M000011.html +32 -0
- data/doc/classes/Pidify.src/M000012.html +20 -0
- data/doc/classes/Pidify.src/M000013.html +24 -0
- data/doc/created.rid +1 -1
- data/doc/files/pidify_rb.html +10 -1
- data/doc/fr_method_index.html +10 -6
- data/lib/pidify.rb +30 -4
- metadata +10 -6
data/doc/classes/Pidify.html
CHANGED
@@ -94,14 +94,11 @@ A more useful example:
|
|
94
94
|
</p>
|
95
95
|
<pre>
|
96
96
|
require 'pidify'
|
97
|
-
require 'daemons'
|
98
97
|
Signal.trap('INT') { Pidify.stop; exit }
|
99
98
|
module Doer
|
100
99
|
def self.start
|
101
100
|
puts "starting"
|
102
|
-
|
103
|
-
Daemons.daemonize
|
104
|
-
Pidify.start
|
101
|
+
Pidify.start_as_daemon
|
105
102
|
loop do
|
106
103
|
puts "hello world"
|
107
104
|
sleep 1
|
@@ -126,15 +123,19 @@ A more useful example:
|
|
126
123
|
<h3 class="section-bar">Methods</h3>
|
127
124
|
|
128
125
|
<div class="name-list">
|
129
|
-
<a href="#
|
130
|
-
<a href="#
|
126
|
+
<a href="#M000013">daemonize</a>
|
127
|
+
<a href="#M000008">delete_pid</a>
|
128
|
+
<a href="#M000006">pid</a>
|
131
129
|
<a href="#M000001">pid_directory</a>
|
132
130
|
<a href="#M000002">pid_directory=</a>
|
131
|
+
<a href="#M000011">pid_end</a>
|
132
|
+
<a href="#M000004">pid_exists?</a>
|
133
133
|
<a href="#M000003">pid_file</a>
|
134
|
-
<a href="#
|
135
|
-
<a href="#
|
136
|
-
<a href="#
|
137
|
-
<a href="#
|
134
|
+
<a href="#M000005">running?</a>
|
135
|
+
<a href="#M000007">save_pid</a>
|
136
|
+
<a href="#M000009">start</a>
|
137
|
+
<a href="#M000012">start_as_daemon</a>
|
138
|
+
<a href="#M000010">stop</a>
|
138
139
|
</div>
|
139
140
|
</div>
|
140
141
|
|
@@ -156,32 +157,56 @@ A more useful example:
|
|
156
157
|
<div id="methods">
|
157
158
|
<h3 class="section-bar">Public Class methods</h3>
|
158
159
|
|
159
|
-
<div id="method-
|
160
|
-
<a name="
|
160
|
+
<div id="method-M000013" class="method-detail">
|
161
|
+
<a name="M000013"></a>
|
161
162
|
|
162
163
|
<div class="method-heading">
|
163
|
-
<a href="Pidify.src/
|
164
|
-
onclick="popupCode('Pidify.src/
|
164
|
+
<a href="Pidify.src/M000013.html" target="Code" class="method-signature"
|
165
|
+
onclick="popupCode('Pidify.src/M000013.html');return false;">
|
166
|
+
<span class="method-name">daemonize</span><span class="method-args">()</span>
|
167
|
+
</a>
|
168
|
+
</div>
|
169
|
+
|
170
|
+
<div class="method-description">
|
171
|
+
<p>
|
172
|
+
Daemonizes this process. Does not automatically use a PID file. If you want
|
173
|
+
to use a PID file, you must call <a
|
174
|
+
href="Pidify.html#M000009">Pidify.start</a> after the call to <a
|
175
|
+
href="Pidify.html#M000013">daemonize</a> or use <a
|
176
|
+
href="Pidify.html#M000012">Pidify.start_as_daemon</a>.
|
177
|
+
</p>
|
178
|
+
</div>
|
179
|
+
</div>
|
180
|
+
|
181
|
+
<div id="method-M000008" class="method-detail">
|
182
|
+
<a name="M000008"></a>
|
183
|
+
|
184
|
+
<div class="method-heading">
|
185
|
+
<a href="Pidify.src/M000008.html" target="Code" class="method-signature"
|
186
|
+
onclick="popupCode('Pidify.src/M000008.html');return false;">
|
165
187
|
<span class="method-name">delete_pid</span><span class="method-args">()</span>
|
166
188
|
</a>
|
167
189
|
</div>
|
168
190
|
|
169
191
|
<div class="method-description">
|
170
192
|
<p>
|
171
|
-
Deletes the PID file. Calling stop calls
|
172
|
-
try to send a kill signal to the running
|
173
|
-
this one. BEWARE that this tries to delete
|
174
|
-
href="Pidify.html#M000003">pid_file</a> and
|
193
|
+
Deletes the PID file. Calling <a href="Pidify.html#M000010">stop</a> calls
|
194
|
+
this automatically, but will also try to send a kill signal to the running
|
195
|
+
process, if it is different from this one. BEWARE that this tries to delete
|
196
|
+
whatever file is returned by <a href="Pidify.html#M000003">pid_file</a> and
|
197
|
+
does no error checking on it! Returns true if the delete was successful,
|
198
|
+
false if there was an error, and nil if the <a
|
199
|
+
href="Pidify.html#M000006">pid</a> file doesn‘t exist.
|
175
200
|
</p>
|
176
201
|
</div>
|
177
202
|
</div>
|
178
203
|
|
179
|
-
<div id="method-
|
180
|
-
<a name="
|
204
|
+
<div id="method-M000006" class="method-detail">
|
205
|
+
<a name="M000006"></a>
|
181
206
|
|
182
207
|
<div class="method-heading">
|
183
|
-
<a href="Pidify.src/
|
184
|
-
onclick="popupCode('Pidify.src/
|
208
|
+
<a href="Pidify.src/M000006.html" target="Code" class="method-signature"
|
209
|
+
onclick="popupCode('Pidify.src/M000006.html');return false;">
|
185
210
|
<span class="method-name">pid</span><span class="method-args">()</span>
|
186
211
|
</a>
|
187
212
|
</div>
|
@@ -189,7 +214,8 @@ href="Pidify.html#M000003">pid_file</a> and does no error checking on it!
|
|
189
214
|
<div class="method-description">
|
190
215
|
<p>
|
191
216
|
Returns the PID stored in the <a href="Pidify.html#M000003">pid_file</a>
|
192
|
-
(not necessarily the PID of this script).
|
217
|
+
(not necessarily the PID of this script). Returns nil if no PID exists or
|
218
|
+
if there is a problem with the read.
|
193
219
|
</p>
|
194
220
|
</div>
|
195
221
|
</div>
|
@@ -224,15 +250,53 @@ Returns the Pathname of the PID storage directory (defaults to /var/run).
|
|
224
250
|
<div class="method-description">
|
225
251
|
<p>
|
226
252
|
Sets the PID storage directory (defaults to /var/run). Be VERY CAREFUL
|
227
|
-
using this, as <a href="Pidify.html#
|
253
|
+
using this, as <a href="Pidify.html#M000008">delete_pid</a> will try to
|
228
254
|
delete whatever file it thinks is the <a
|
229
255
|
href="Pidify.html#M000003">pid_file</a> for this script in the <a
|
230
|
-
href="Pidify.html#M000001">pid_directory</a>. It&#
|
256
|
+
href="Pidify.html#M000001">pid_directory</a>. It‘s probably a good
|
231
257
|
idea not to change this at all.
|
232
258
|
</p>
|
233
259
|
</div>
|
234
260
|
</div>
|
235
261
|
|
262
|
+
<div id="method-M000011" class="method-detail">
|
263
|
+
<a name="M000011"></a>
|
264
|
+
|
265
|
+
<div class="method-heading">
|
266
|
+
<a href="Pidify.src/M000011.html" target="Code" class="method-signature"
|
267
|
+
onclick="popupCode('Pidify.src/M000011.html');return false;">
|
268
|
+
<span class="method-name">pid_end</span><span class="method-args">(signals=%w(SIGTERM SIGQUIT SIGKILL), secs_between_signal=4)</span>
|
269
|
+
</a>
|
270
|
+
</div>
|
271
|
+
|
272
|
+
<div class="method-description">
|
273
|
+
<p>
|
274
|
+
Sends each kill signal to the saved PID, pausing for secs_between_signal
|
275
|
+
after each to check if it the process remains running. Stops when the
|
276
|
+
process has ended or when all signals have been tried. Returns true if the
|
277
|
+
process was killed or false otherwise.
|
278
|
+
</p>
|
279
|
+
</div>
|
280
|
+
</div>
|
281
|
+
|
282
|
+
<div id="method-M000004" class="method-detail">
|
283
|
+
<a name="M000004"></a>
|
284
|
+
|
285
|
+
<div class="method-heading">
|
286
|
+
<a href="Pidify.src/M000004.html" target="Code" class="method-signature"
|
287
|
+
onclick="popupCode('Pidify.src/M000004.html');return false;">
|
288
|
+
<span class="method-name">pid_exists?</span><span class="method-args">()</span>
|
289
|
+
</a>
|
290
|
+
</div>
|
291
|
+
|
292
|
+
<div class="method-description">
|
293
|
+
<p>
|
294
|
+
Returns true if the <a href="Pidify.html#M000003">pid_file</a> exists for
|
295
|
+
this script.
|
296
|
+
</p>
|
297
|
+
</div>
|
298
|
+
</div>
|
299
|
+
|
236
300
|
<div id="method-M000003" class="method-detail">
|
237
301
|
<a name="M000003"></a>
|
238
302
|
|
@@ -250,29 +314,30 @@ Returns the PID filename as a Pathname.
|
|
250
314
|
</div>
|
251
315
|
</div>
|
252
316
|
|
253
|
-
<div id="method-
|
254
|
-
<a name="
|
317
|
+
<div id="method-M000005" class="method-detail">
|
318
|
+
<a name="M000005"></a>
|
255
319
|
|
256
320
|
<div class="method-heading">
|
257
|
-
<a href="Pidify.src/
|
258
|
-
onclick="popupCode('Pidify.src/
|
321
|
+
<a href="Pidify.src/M000005.html" target="Code" class="method-signature"
|
322
|
+
onclick="popupCode('Pidify.src/M000005.html');return false;">
|
259
323
|
<span class="method-name">running?</span><span class="method-args">()</span>
|
260
324
|
</a>
|
261
325
|
</div>
|
262
326
|
|
263
327
|
<div class="method-description">
|
264
328
|
<p>
|
265
|
-
Returns true if the
|
329
|
+
Returns true if the process using <a href="Pidify.html#M000006">pid</a> is
|
330
|
+
running.
|
266
331
|
</p>
|
267
332
|
</div>
|
268
333
|
</div>
|
269
334
|
|
270
|
-
<div id="method-
|
271
|
-
<a name="
|
335
|
+
<div id="method-M000007" class="method-detail">
|
336
|
+
<a name="M000007"></a>
|
272
337
|
|
273
338
|
<div class="method-heading">
|
274
|
-
<a href="Pidify.src/
|
275
|
-
onclick="popupCode('Pidify.src/
|
339
|
+
<a href="Pidify.src/M000007.html" target="Code" class="method-signature"
|
340
|
+
onclick="popupCode('Pidify.src/M000007.html');return false;">
|
276
341
|
<span class="method-name">save_pid</span><span class="method-args">()</span>
|
277
342
|
</a>
|
278
343
|
</div>
|
@@ -280,17 +345,20 @@ Returns true if the PID file exists for this script.
|
|
280
345
|
<div class="method-description">
|
281
346
|
<p>
|
282
347
|
Saves the PID of this script into the <a
|
283
|
-
href="Pidify.html#M000003">pid_file</a>. Automatically called by
|
348
|
+
href="Pidify.html#M000003">pid_file</a>. Automatically called by <a
|
349
|
+
href="Pidify.html#M000009">start</a>. Returns nil if the <a
|
350
|
+
href="Pidify.html#M000006">pid</a> file already exists. Returns true if
|
351
|
+
successful, false if there was a write problem.
|
284
352
|
</p>
|
285
353
|
</div>
|
286
354
|
</div>
|
287
355
|
|
288
|
-
<div id="method-
|
289
|
-
<a name="
|
356
|
+
<div id="method-M000009" class="method-detail">
|
357
|
+
<a name="M000009"></a>
|
290
358
|
|
291
359
|
<div class="method-heading">
|
292
|
-
<a href="Pidify.src/
|
293
|
-
onclick="popupCode('Pidify.src/
|
360
|
+
<a href="Pidify.src/M000009.html" target="Code" class="method-signature"
|
361
|
+
onclick="popupCode('Pidify.src/M000009.html');return false;">
|
294
362
|
<span class="method-name">start</span><span class="method-args">()</span>
|
295
363
|
</a>
|
296
364
|
</div>
|
@@ -299,26 +367,48 @@ href="Pidify.html#M000003">pid_file</a>. Automatically called by start.
|
|
299
367
|
<p>
|
300
368
|
Saves the PID of this script into the <a
|
301
369
|
href="Pidify.html#M000003">pid_file</a> by calling <a
|
302
|
-
href="Pidify.html#
|
303
|
-
returns false.
|
370
|
+
href="Pidify.html#M000007">save_pid</a>. Raises an exception if <a
|
371
|
+
href="Pidify.html#M000004">pid_exists?</a> returns false. Returns true if
|
372
|
+
successful.
|
304
373
|
</p>
|
305
374
|
</div>
|
306
375
|
</div>
|
307
376
|
|
308
|
-
<div id="method-
|
309
|
-
<a name="
|
377
|
+
<div id="method-M000012" class="method-detail">
|
378
|
+
<a name="M000012"></a>
|
310
379
|
|
311
380
|
<div class="method-heading">
|
312
|
-
<a href="Pidify.src/
|
313
|
-
onclick="popupCode('Pidify.src/
|
314
|
-
<span class="method-name">
|
381
|
+
<a href="Pidify.src/M000012.html" target="Code" class="method-signature"
|
382
|
+
onclick="popupCode('Pidify.src/M000012.html');return false;">
|
383
|
+
<span class="method-name">start_as_daemon</span><span class="method-args">()</span>
|
384
|
+
</a>
|
385
|
+
</div>
|
386
|
+
|
387
|
+
<div class="method-description">
|
388
|
+
<p>
|
389
|
+
Like <a href="Pidify.html#M000009">Pidify.start</a>, but first calls <a
|
390
|
+
href="Pidify.html#M000013">Pidify.daemonize</a>. Will fail and raise an
|
391
|
+
exception if Pidify.running? returns true.
|
392
|
+
</p>
|
393
|
+
</div>
|
394
|
+
</div>
|
395
|
+
|
396
|
+
<div id="method-M000010" class="method-detail">
|
397
|
+
<a name="M000010"></a>
|
398
|
+
|
399
|
+
<div class="method-heading">
|
400
|
+
<a href="Pidify.src/M000010.html" target="Code" class="method-signature"
|
401
|
+
onclick="popupCode('Pidify.src/M000010.html');return false;">
|
402
|
+
<span class="method-name">stop</span><span class="method-args">(signals=%w(SIGTERM SIGQUIT SIGKILL), secs_between_signal=4)</span>
|
315
403
|
</a>
|
316
404
|
</div>
|
317
405
|
|
318
406
|
<div class="method-description">
|
319
407
|
<p>
|
320
408
|
Deletes the saved PID file and, if the PID belongs to a process different
|
321
|
-
from this script, sends
|
409
|
+
from this script, sends kill signals to the saved PID using <a
|
410
|
+
href="Pidify.html#M000011">pid_end</a>. Returns true if the process was
|
411
|
+
killed or false otherwise.
|
322
412
|
</p>
|
323
413
|
</div>
|
324
414
|
</div>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File pidify.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 77</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pid_directory</span>
|
15
15
|
<span class="ruby-ivar">@pid_directory</span>
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File pidify.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 85</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pid_directory=</span>(<span class="ruby-identifier">dir</span>)
|
15
15
|
<span class="ruby-ivar">@pid_directory</span> = <span class="ruby-constant">Pathname</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dir</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Pathname</span>
|
16
16
|
<span class="ruby-ivar">@pid_directory</span> = <span class="ruby-identifier">dir</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Pathname</span>
|
@@ -10,9 +10,9 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File pidify.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 91</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pid_file</span>
|
15
|
-
<span class="ruby-ivar">@pid_directory</span> <span class="ruby-operator">+</span> (<span class="ruby-constant">Pathname</span>.<span class="ruby-identifier">new</span>(<span class="ruby-
|
15
|
+
<span class="ruby-ivar">@pid_directory</span> <span class="ruby-operator">+</span> (<span class="ruby-constant">Pathname</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@file_name</span>).<span class="ruby-identifier">basename</span>.<span class="ruby-identifier">to_s</span><span class="ruby-operator">+</span><span class="ruby-value str">'.pid'</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
18
18
|
</html>
|
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>pid_exists? (Pidify)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File pidify.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 96</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pid_exists?</span>
|
15
15
|
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">FileTest</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">pid_file</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
@@ -5,16 +5,20 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>running? (Pidify)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File pidify.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
<span class="ruby-
|
16
|
-
<span class="ruby-
|
17
|
-
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 101</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">running?</span>
|
15
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">pid_exists?</span>
|
16
|
+
<span class="ruby-keyword kw">begin</span>
|
17
|
+
<span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-identifier">kill</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">pid</span>
|
18
|
+
<span class="ruby-keyword kw">true</span>
|
19
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ESRCH</span>
|
20
|
+
<span class="ruby-keyword kw">false</span>
|
21
|
+
<span class="ruby-keyword kw">end</span>
|
18
22
|
<span class="ruby-keyword kw">end</span></pre>
|
19
23
|
</body>
|
20
24
|
</html>
|
@@ -5,14 +5,22 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>pid (Pidify)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File pidify.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
<span class="ruby-
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 114</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pid</span>
|
15
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">pid_exists?</span>
|
16
|
+
<span class="ruby-identifier">dpid</span> = <span class="ruby-keyword kw">nil</span>
|
17
|
+
<span class="ruby-keyword kw">begin</span>
|
18
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">pid_file</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">RDONLY</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span> <span class="ruby-identifier">dpid</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">gets</span>.<span class="ruby-identifier">chomp</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">flock</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">LOCK_SH</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">LOCK_NB</span>); <span class="ruby-identifier">file</span>.<span class="ruby-identifier">flock</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">LOCK_UN</span>) }
|
19
|
+
<span class="ruby-keyword kw">rescue</span>
|
20
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
21
|
+
<span class="ruby-keyword kw">end</span>
|
22
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">dpid</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dpid</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">dpid</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
23
|
+
<span class="ruby-keyword kw">nil</span>
|
16
24
|
<span class="ruby-keyword kw">end</span></pre>
|
17
25
|
</body>
|
18
26
|
</html>
|
@@ -5,14 +5,20 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>save_pid (Pidify)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File pidify.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
<span class="ruby-
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 129</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_pid</span>
|
15
|
+
<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">pid_exists?</span>
|
16
|
+
<span class="ruby-keyword kw">begin</span>
|
17
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">pid_file</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">CREAT</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">EXCL</span><span class="ruby-operator">|</span><span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRONLY</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">$$</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">flock</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">LOCK_EX</span>); <span class="ruby-identifier">file</span>.<span class="ruby-identifier">flock</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">LOCK_UN</span>) }
|
18
|
+
<span class="ruby-keyword kw">true</span>
|
19
|
+
<span class="ruby-keyword kw">rescue</span>
|
20
|
+
<span class="ruby-keyword kw">false</span>
|
21
|
+
<span class="ruby-keyword kw">end</span>
|
16
22
|
<span class="ruby-keyword kw">end</span></pre>
|
17
23
|
</body>
|
18
24
|
</html>
|
@@ -5,15 +5,21 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>delete_pid (Pidify)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File pidify.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
<span class="ruby-
|
16
|
-
<span class="ruby-
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 145</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_pid</span>
|
15
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">pid_exists?</span>
|
16
|
+
<span class="ruby-keyword kw">begin</span>
|
17
|
+
<span class="ruby-comment cmt"># FIXME: lock first?</span>
|
18
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">pid_file</span>)
|
19
|
+
<span class="ruby-keyword kw">true</span>
|
20
|
+
<span class="ruby-keyword kw">rescue</span>
|
21
|
+
<span class="ruby-keyword kw">false</span>
|
22
|
+
<span class="ruby-keyword kw">end</span>
|
17
23
|
<span class="ruby-keyword kw">end</span></pre>
|
18
24
|
</body>
|
19
25
|
</html>
|
@@ -5,27 +5,15 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>start (Pidify)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File pidify.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">
|
16
|
-
|
17
|
-
<span class="ruby-identifier">pid</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">pid</span>
|
18
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pid</span>
|
19
|
-
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-identifier">signal</span>, <span class="ruby-identifier">pid</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pid</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">$$</span>
|
20
|
-
<span class="ruby-identifier">delete_pid</span>
|
21
|
-
<span class="ruby-keyword kw">else</span>
|
22
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Failed to stop: no PID found."</span>
|
23
|
-
<span class="ruby-keyword kw">end</span>
|
24
|
-
<span class="ruby-keyword kw">rescue</span>
|
25
|
-
<span class="ruby-identifier">delete_pid</span>
|
26
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Failed to stop: process already stopped; deleted PID file."</span>
|
27
|
-
<span class="ruby-keyword kw">end</span>
|
28
|
-
<span class="ruby-keyword kw">end</span>
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 159</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>
|
15
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Failed to start: already running (PID file exists)."</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pid_exists?</span>
|
16
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">save_pid</span>
|
29
17
|
<span class="ruby-keyword kw">end</span></pre>
|
30
18
|
</body>
|
31
19
|
</html>
|
@@ -0,0 +1,27 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>stop (Pidify)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 167</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop</span>(<span class="ruby-identifier">signals</span>=<span class="ruby-node">%w(SIGTERM SIGQUIT SIGKILL)</span>, <span class="ruby-identifier">secs_between_signal</span>=<span class="ruby-value">4</span>)
|
15
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">pid_exists?</span>
|
16
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">running?</span>
|
17
|
+
<span class="ruby-identifier">delete_pid</span>
|
18
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
19
|
+
<span class="ruby-keyword kw">end</span>
|
20
|
+
<span class="ruby-identifier">pid</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">pid</span>
|
21
|
+
<span class="ruby-identifier">killed</span> = <span class="ruby-keyword kw">true</span>
|
22
|
+
<span class="ruby-identifier">killed</span> = <span class="ruby-identifier">pid_end</span>(<span class="ruby-identifier">signals</span>, <span class="ruby-identifier">secs_between_signal</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pid</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">$$</span>
|
23
|
+
<span class="ruby-identifier">delete_pid</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">killed</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
|
24
|
+
<span class="ruby-identifier">killed</span>
|
25
|
+
<span class="ruby-keyword kw">end</span></pre>
|
26
|
+
</body>
|
27
|
+
</html>
|
@@ -0,0 +1,32 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>pid_end (Pidify)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 184</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pid_end</span>(<span class="ruby-identifier">signals</span>=<span class="ruby-node">%w(SIGTERM SIGQUIT SIGKILL)</span>, <span class="ruby-identifier">secs_between_signal</span>=<span class="ruby-value">4</span>)
|
15
|
+
<span class="ruby-identifier">pid</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">pid</span>
|
16
|
+
<span class="ruby-identifier">signals</span> = [ <span class="ruby-identifier">signals</span> ].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">sig</span><span class="ruby-operator">|</span> <span class="ruby-identifier">sig</span>.<span class="ruby-identifier">to_s</span>}
|
17
|
+
<span class="ruby-identifier">existed</span> = <span class="ruby-keyword kw">false</span>
|
18
|
+
<span class="ruby-identifier">signals</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">sig</span><span class="ruby-operator">|</span>
|
19
|
+
<span class="ruby-keyword kw">begin</span>
|
20
|
+
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-identifier">sig</span>, <span class="ruby-identifier">pid</span>)
|
21
|
+
<span class="ruby-identifier">existed</span> = <span class="ruby-keyword kw">true</span>
|
22
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ESRCH</span>
|
23
|
+
<span class="ruby-keyword kw">return</span> (<span class="ruby-identifier">existed</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>)
|
24
|
+
<span class="ruby-keyword kw">end</span>
|
25
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">running?</span>
|
26
|
+
<span class="ruby-identifier">sleep</span> <span class="ruby-identifier">secs_between_signal</span>
|
27
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">running?</span>
|
28
|
+
<span class="ruby-keyword kw">end</span>
|
29
|
+
<span class="ruby-keyword kw">not</span> <span class="ruby-identifier">running?</span>
|
30
|
+
<span class="ruby-keyword kw">end</span></pre>
|
31
|
+
</body>
|
32
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>start_as_daemon (Pidify)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 204</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start_as_daemon</span>
|
15
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Failed to start: already running."</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">running?</span>
|
16
|
+
<span class="ruby-identifier">daemonize</span>
|
17
|
+
<span class="ruby-identifier">start</span>
|
18
|
+
<span class="ruby-keyword kw">end</span></pre>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,24 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>daemonize (Pidify)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File pidify.rb, line 213</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">daemonize</span>
|
15
|
+
<span class="ruby-identifier">fork</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">exit</span>
|
16
|
+
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
|
17
|
+
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span> <span class="ruby-value str">'/'</span>
|
18
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
|
19
|
+
<span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">"/dev/null"</span>
|
20
|
+
<span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">"/dev/null"</span>, <span class="ruby-value str">"a"</span>
|
21
|
+
<span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-constant">STDOUT</span>
|
22
|
+
<span class="ruby-keyword kw">end</span></pre>
|
23
|
+
</body>
|
24
|
+
</html>
|
data/doc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Tue Nov 07 11:49:54 -0500 2006
|
data/doc/files/pidify_rb.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Tue Nov 07 11:42:34 -0500 2006</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -86,6 +86,15 @@ PID files it creates and maintains.
|
|
86
86
|
See <a href="../classes/Pidify.html">Pidify</a> for more information and
|
87
87
|
examples.
|
88
88
|
</p>
|
89
|
+
<h2>Website</h2>
|
90
|
+
<p>
|
91
|
+
Documentation: <a
|
92
|
+
href="http://pidify.rubyforge.org">pidify.rubyforge.org</a>/
|
93
|
+
</p>
|
94
|
+
<p>
|
95
|
+
Rubyforge page and Download: <a
|
96
|
+
href="http://rubyforge.org/projects/pidify">rubyforge.org/projects/pidify</a>/
|
97
|
+
</p>
|
89
98
|
<h2>Requirements</h2>
|
90
99
|
<ul>
|
91
100
|
<li>Ruby 1.8
|
data/doc/fr_method_index.html
CHANGED
@@ -20,15 +20,19 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Methods</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/Pidify.html#
|
24
|
-
<a href="classes/Pidify.html#
|
23
|
+
<a href="classes/Pidify.html#M000013">daemonize (Pidify)</a><br />
|
24
|
+
<a href="classes/Pidify.html#M000008">delete_pid (Pidify)</a><br />
|
25
|
+
<a href="classes/Pidify.html#M000006">pid (Pidify)</a><br />
|
25
26
|
<a href="classes/Pidify.html#M000001">pid_directory (Pidify)</a><br />
|
26
27
|
<a href="classes/Pidify.html#M000002">pid_directory= (Pidify)</a><br />
|
28
|
+
<a href="classes/Pidify.html#M000011">pid_end (Pidify)</a><br />
|
29
|
+
<a href="classes/Pidify.html#M000004">pid_exists? (Pidify)</a><br />
|
27
30
|
<a href="classes/Pidify.html#M000003">pid_file (Pidify)</a><br />
|
28
|
-
<a href="classes/Pidify.html#
|
29
|
-
<a href="classes/Pidify.html#
|
30
|
-
<a href="classes/Pidify.html#
|
31
|
-
<a href="classes/Pidify.html#
|
31
|
+
<a href="classes/Pidify.html#M000005">running? (Pidify)</a><br />
|
32
|
+
<a href="classes/Pidify.html#M000007">save_pid (Pidify)</a><br />
|
33
|
+
<a href="classes/Pidify.html#M000009">start (Pidify)</a><br />
|
34
|
+
<a href="classes/Pidify.html#M000012">start_as_daemon (Pidify)</a><br />
|
35
|
+
<a href="classes/Pidify.html#M000010">stop (Pidify)</a><br />
|
32
36
|
</div>
|
33
37
|
</div>
|
34
38
|
</body>
|
data/lib/pidify.rb
CHANGED
@@ -12,6 +12,14 @@
|
|
12
12
|
# files it creates and maintains.
|
13
13
|
#
|
14
14
|
# See Pidify for more information and examples.
|
15
|
+
#
|
16
|
+
# == Website
|
17
|
+
#
|
18
|
+
# Documentation:
|
19
|
+
# http://pidify.rubyforge.org/
|
20
|
+
#
|
21
|
+
# Rubyforge page and Download:
|
22
|
+
# http://rubyforge.org/projects/pidify/
|
15
23
|
#
|
16
24
|
# == Requirements
|
17
25
|
#
|
@@ -40,14 +48,11 @@
|
|
40
48
|
#
|
41
49
|
# A more useful example:
|
42
50
|
# require 'pidify'
|
43
|
-
# require 'daemons'
|
44
51
|
# Signal.trap('INT') { Pidify.stop; exit }
|
45
52
|
# module Doer
|
46
53
|
# def self.start
|
47
54
|
# puts "starting"
|
48
|
-
#
|
49
|
-
# Daemons.daemonize
|
50
|
-
# Pidify.start
|
55
|
+
# Pidify.start_as_daemon
|
51
56
|
# loop do
|
52
57
|
# puts "hello world"
|
53
58
|
# sleep 1
|
@@ -193,5 +198,26 @@ module Pidify
|
|
193
198
|
end
|
194
199
|
not running?
|
195
200
|
end
|
201
|
+
|
202
|
+
# Like Pidify.start, but first calls Pidify.daemonize. Will fail and raise
|
203
|
+
# an exception if Pidify.running? returns true.
|
204
|
+
def start_as_daemon
|
205
|
+
raise "Failed to start: already running." if running?
|
206
|
+
daemonize
|
207
|
+
start
|
208
|
+
end
|
209
|
+
|
210
|
+
# Daemonizes this process. Does not automatically use a PID file. If you
|
211
|
+
# want to use a PID file, you must call Pidify.start after the call to
|
212
|
+
# daemonize or use Pidify.start_as_daemon.
|
213
|
+
def daemonize
|
214
|
+
fork and exit
|
215
|
+
Process.setsid
|
216
|
+
Dir.chdir '/'
|
217
|
+
File.umask 0000
|
218
|
+
STDIN.reopen "/dev/null"
|
219
|
+
STDOUT.reopen "/dev/null", "a"
|
220
|
+
STDERR.reopen STDOUT
|
221
|
+
end
|
196
222
|
end
|
197
223
|
end
|
metadata
CHANGED
@@ -3,13 +3,13 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: pidify
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-11-
|
8
|
-
summary: This allows a script to check if there is currently another running instance of itself, and give it the ability to kill that instance based on PID.
|
6
|
+
version: "0.2"
|
7
|
+
date: 2006-11-07 00:00:00 -05:00
|
8
|
+
summary: This allows a script to check if there is currently another running instance of itself (like a daemon), and give it the ability to kill that instance based on PID.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: payton@foolord.com
|
12
|
-
homepage: http://
|
12
|
+
homepage: http://pidify.rubyforge.org/
|
13
13
|
rubyforge_project:
|
14
14
|
description:
|
15
15
|
autorequire:
|
@@ -33,13 +33,14 @@ files:
|
|
33
33
|
- doc/classes
|
34
34
|
- doc/fr_file_index.html
|
35
35
|
- doc/fr_method_index.html
|
36
|
-
- doc/rdoc-style.css
|
37
36
|
- doc/created.rid
|
38
|
-
- doc/index.html
|
39
37
|
- doc/fr_class_index.html
|
38
|
+
- doc/index.html
|
39
|
+
- doc/rdoc-style.css
|
40
40
|
- doc/files/pidify_rb.html
|
41
41
|
- doc/classes/Pidify.src
|
42
42
|
- doc/classes/Pidify.html
|
43
|
+
- doc/classes/Pidify.src/M000010.html
|
43
44
|
- doc/classes/Pidify.src/M000001.html
|
44
45
|
- doc/classes/Pidify.src/M000002.html
|
45
46
|
- doc/classes/Pidify.src/M000003.html
|
@@ -49,6 +50,9 @@ files:
|
|
49
50
|
- doc/classes/Pidify.src/M000007.html
|
50
51
|
- doc/classes/Pidify.src/M000008.html
|
51
52
|
- doc/classes/Pidify.src/M000009.html
|
53
|
+
- doc/classes/Pidify.src/M000011.html
|
54
|
+
- doc/classes/Pidify.src/M000012.html
|
55
|
+
- doc/classes/Pidify.src/M000013.html
|
52
56
|
test_files: []
|
53
57
|
|
54
58
|
rdoc_options: []
|