mlanett-daemons 1.0.13 → 1.1.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. data/Gemfile.lock +12 -2
  2. data/LICENSE +1 -8
  3. data/README-mlanett.rdoc +8 -0
  4. data/{README → README.rdoc} +6 -15
  5. data/Releases +84 -9
  6. data/TODO +1 -5
  7. data/daemons.gemspec +1 -0
  8. data/examples/call/call.rb +1 -0
  9. data/examples/daemonize/daemonize.rb +10 -3
  10. data/examples/run/ctrl_hanging.rb +19 -0
  11. data/examples/run/ctrl_monitor_multiple.rb +18 -0
  12. data/examples/run/ctrl_normal.rb +0 -1
  13. data/examples/run/ctrl_proc.rb.output +20 -0
  14. data/examples/run/ctrl_proc_rand.rb +23 -0
  15. data/examples/run/ctrl_slowstop.rb +16 -0
  16. data/examples/run/myserver_crashing.rb +2 -2
  17. data/examples/run/myserver_hanging.rb +21 -0
  18. data/examples/run/myserver_slowstop.rb +21 -0
  19. data/lib/daemons.rb +38 -10
  20. data/lib/daemons/application.rb +131 -26
  21. data/lib/daemons/application_group.rb +58 -10
  22. data/lib/daemons/change_privilege.rb +19 -0
  23. data/lib/daemons/cmdline.rb +10 -6
  24. data/lib/daemons/controller.rb +5 -2
  25. data/lib/daemons/daemonize.rb +64 -150
  26. data/lib/daemons/etc_extension.rb +12 -0
  27. data/lib/daemons/exceptions.rb +3 -0
  28. data/lib/daemons/monitor.rb +27 -19
  29. data/lib/daemons/pid.rb +13 -14
  30. data/lib/daemons/pidfile.rb +14 -7
  31. data/lib/daemons/pidmem.rb +9 -0
  32. data/lib/daemons/version.rb +1 -1
  33. data/spec/pidfile_spec.rb +12 -0
  34. data/spec/spec_helper.rb +1 -0
  35. metadata +31 -47
  36. data/daemons.tmproj +0 -56
  37. data/examples/run/myserver_crashing.rb.output +0 -30
  38. data/html/classes/Daemonize.html +0 -497
  39. data/html/classes/Daemons.html +0 -683
  40. data/html/classes/Daemons/Application.html +0 -836
  41. data/html/classes/Daemons/ApplicationGroup.html +0 -508
  42. data/html/classes/Daemons/CmdException.html +0 -113
  43. data/html/classes/Daemons/Controller.html +0 -429
  44. data/html/classes/Daemons/Error.html +0 -113
  45. data/html/classes/Daemons/Exception.html +0 -111
  46. data/html/classes/Daemons/Monitor.html +0 -263
  47. data/html/classes/Daemons/Optparse.html +0 -244
  48. data/html/classes/Daemons/Pid.html +0 -339
  49. data/html/classes/Daemons/PidFile.html +0 -441
  50. data/html/classes/Daemons/PidMem.html +0 -126
  51. data/html/classes/Daemons/RuntimeException.html +0 -113
  52. data/html/classes/Daemons/SystemError.html +0 -163
  53. data/html/created.rid +0 -1
  54. data/html/files/README.html +0 -377
  55. data/html/files/Releases.html +0 -342
  56. data/html/files/TODO.html +0 -121
  57. data/html/files/lib/daemons/application_group_rb.html +0 -101
  58. data/html/files/lib/daemons/application_rb.html +0 -110
  59. data/html/files/lib/daemons/cmdline_rb.html +0 -101
  60. data/html/files/lib/daemons/controller_rb.html +0 -101
  61. data/html/files/lib/daemons/daemonize_rb.html +0 -207
  62. data/html/files/lib/daemons/exceptions_rb.html +0 -101
  63. data/html/files/lib/daemons/monitor_rb.html +0 -108
  64. data/html/files/lib/daemons/pid_rb.html +0 -108
  65. data/html/files/lib/daemons/pidfile_rb.html +0 -108
  66. data/html/files/lib/daemons/pidmem_rb.html +0 -108
  67. data/html/files/lib/daemons_rb.html +0 -117
  68. data/html/fr_class_index.html +0 -41
  69. data/html/fr_file_index.html +0 -40
  70. data/html/fr_method_index.html +0 -91
  71. data/html/index.html +0 -24
  72. data/html/rdoc-style.css +0 -208
  73. data/test/call_as_daemon.rb +0 -12
  74. data/test/tc_main.rb +0 -24
  75. data/test/test1.rb +0 -19
  76. data/test/testapp.rb +0 -11
@@ -1,113 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Daemons::Error</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::Error</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/daemons/exceptions_rb.html">
59
- lib/daemons/exceptions.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- <a href="Exception.html">
69
- Exception
70
- </a>
71
- </td>
72
- </tr>
73
- </table>
74
- </div>
75
- <!-- banner header -->
76
-
77
- <div id="bodyContent">
78
-
79
-
80
-
81
- <div id="contextContent">
82
-
83
-
84
-
85
- </div>
86
-
87
-
88
- </div>
89
-
90
-
91
- <!-- if includes -->
92
-
93
- <div id="section">
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
- <!-- if method_list -->
103
-
104
-
105
- </div>
106
-
107
-
108
- <div id="validator-badges">
109
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
110
- </div>
111
-
112
- </body>
113
- </html>
@@ -1,111 +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::Exception</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::Exception</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
- ::RuntimeError
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
-
86
- </div>
87
-
88
-
89
- <!-- if includes -->
90
-
91
- <div id="section">
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
- <!-- if method_list -->
101
-
102
-
103
- </div>
104
-
105
-
106
- <div id="validator-badges">
107
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
108
- </div>
109
-
110
- </body>
111
- </html>
@@ -1,263 +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::Monitor</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::Monitor</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/daemons/monitor_rb.html">
59
- lib/daemons/monitor.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="#M000047">find</a>&nbsp;&nbsp;
90
- <a href="#M000048">new</a>&nbsp;&nbsp;
91
- <a href="#M000049">start</a>&nbsp;&nbsp;
92
- <a href="#M000050">stop</a>&nbsp;&nbsp;
93
- </div>
94
- </div>
95
-
96
- </div>
97
-
98
-
99
- <!-- if includes -->
100
-
101
- <div id="section">
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
- <!-- if method_list -->
111
- <div id="methods">
112
- <h3 class="section-bar">Public Class methods</h3>
113
-
114
- <div id="method-M000047" class="method-detail">
115
- <a name="M000047"></a>
116
-
117
- <div class="method-heading">
118
- <a href="#M000047" class="method-signature">
119
- <span class="method-name">find</span><span class="method-args">(dir, app_name)</span>
120
- </a>
121
- </div>
122
-
123
- <div class="method-description">
124
- <p><a class="source-toggle" href="#"
125
- onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
126
- <div class="method-source-code" id="M000047-source">
127
- <pre>
128
- <span class="ruby-comment cmt"># File lib/daemons/monitor.rb, line 8</span>
129
- 8: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-identifier">app_name</span>)
130
- 9: <span class="ruby-identifier">pid</span> = <span class="ruby-constant">PidFile</span>.<span class="ruby-identifier">find_files</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-identifier">app_name</span>, <span class="ruby-keyword kw">false</span>)[<span class="ruby-value">0</span>]
131
- 10:
132
- 11: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pid</span>
133
- 12: <span class="ruby-identifier">pid</span> = <span class="ruby-constant">PidFile</span>.<span class="ruby-identifier">existing</span>(<span class="ruby-identifier">pid</span>)
134
- 13:
135
- 14: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">PidFile</span>.<span class="ruby-identifier">running?</span>(<span class="ruby-identifier">pid</span>.<span class="ruby-identifier">pid</span>)
136
- 15: <span class="ruby-keyword kw">begin</span>; <span class="ruby-identifier">pid</span>.<span class="ruby-identifier">cleanup</span>; <span class="ruby-keyword kw">rescue</span> <span class="ruby-operator">::</span><span class="ruby-constant">Exception</span>; <span class="ruby-keyword kw">end</span>
137
- 16: <span class="ruby-keyword kw">return</span>
138
- 17: <span class="ruby-keyword kw">end</span>
139
- 18:
140
- 19: <span class="ruby-identifier">monitor</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">allocate</span>
141
- 20:
142
- 21: <span class="ruby-identifier">monitor</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-identifier">:@pid</span>, <span class="ruby-identifier">pid</span>)
143
- 22:
144
- 23: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">monitor</span>
145
- 24: <span class="ruby-keyword kw">end</span>
146
- 25:
147
- 26: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
148
- 27: <span class="ruby-keyword kw">end</span>
149
- </pre>
150
- </div>
151
- </div>
152
- </div>
153
-
154
- <div id="method-M000048" class="method-detail">
155
- <a name="M000048"></a>
156
-
157
- <div class="method-heading">
158
- <a href="#M000048" class="method-signature">
159
- <span class="method-name">new</span><span class="method-args">(an_app)</span>
160
- </a>
161
- </div>
162
-
163
- <div class="method-description">
164
- <p><a class="source-toggle" href="#"
165
- onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
166
- <div class="method-source-code" id="M000048-source">
167
- <pre>
168
- <span class="ruby-comment cmt"># File lib/daemons/monitor.rb, line 30</span>
169
- 30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">an_app</span>)
170
- 31: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">an_app</span>
171
- 32: <span class="ruby-ivar">@app_name</span> = <span class="ruby-identifier">an_app</span>.<span class="ruby-identifier">group</span>.<span class="ruby-identifier">app_name</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'_monitor'</span>
172
- 33:
173
- 34: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">an_app</span>.<span class="ruby-identifier">pidfile_dir</span>
174
- 35: <span class="ruby-ivar">@pid</span> = <span class="ruby-constant">PidFile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">an_app</span>.<span class="ruby-identifier">pidfile_dir</span>, <span class="ruby-ivar">@app_name</span>, <span class="ruby-keyword kw">false</span>)
175
- 36: <span class="ruby-keyword kw">else</span>
176
- 37: <span class="ruby-ivar">@pid</span> = <span class="ruby-constant">PidMem</span>.<span class="ruby-identifier">new</span>
177
- 38: <span class="ruby-keyword kw">end</span>
178
- 39: <span class="ruby-keyword kw">end</span>
179
- </pre>
180
- </div>
181
- </div>
182
- </div>
183
-
184
- <h3 class="section-bar">Public Instance methods</h3>
185
-
186
- <div id="method-M000049" class="method-detail">
187
- <a name="M000049"></a>
188
-
189
- <div class="method-heading">
190
- <a href="#M000049" class="method-signature">
191
- <span class="method-name">start</span><span class="method-args">(applications)</span>
192
- </a>
193
- </div>
194
-
195
- <div class="method-description">
196
- <p><a class="source-toggle" href="#"
197
- onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
198
- <div class="method-source-code" id="M000049-source">
199
- <pre>
200
- <span class="ruby-comment cmt"># File lib/daemons/monitor.rb, line 107</span>
201
- 107: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>(<span class="ruby-identifier">applications</span>)
202
- 108: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">applications</span>.<span class="ruby-identifier">empty?</span>
203
- 109:
204
- 110: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@pid</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">PidFile</span>)
205
- 111: <span class="ruby-identifier">start_with_pidfile</span>(<span class="ruby-identifier">applications</span>)
206
- 112: <span class="ruby-keyword kw">else</span>
207
- 113: <span class="ruby-identifier">start_without_pidfile</span>(<span class="ruby-identifier">applications</span>)
208
- 114: <span class="ruby-keyword kw">end</span>
209
- 115: <span class="ruby-keyword kw">end</span>
210
- </pre>
211
- </div>
212
- </div>
213
- </div>
214
-
215
- <div id="method-M000050" class="method-detail">
216
- <a name="M000050"></a>
217
-
218
- <div class="method-heading">
219
- <a href="#M000050" class="method-signature">
220
- <span class="method-name">stop</span><span class="method-args">()</span>
221
- </a>
222
- </div>
223
-
224
- <div class="method-description">
225
- <p><a class="source-toggle" href="#"
226
- onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
227
- <div class="method-source-code" id="M000050-source">
228
- <pre>
229
- <span class="ruby-comment cmt"># File lib/daemons/monitor.rb, line 118</span>
230
- 118: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop</span>
231
- 119: <span class="ruby-identifier">pid</span> = <span class="ruby-ivar">@pid</span>.<span class="ruby-identifier">pid</span>
232
- 120: <span class="ruby-keyword kw">begin</span>
233
- 121: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-constant">Application</span><span class="ruby-operator">::</span><span class="ruby-constant">SIGNAL</span>, <span class="ruby-identifier">pid</span>)
234
- 122: <span class="ruby-keyword kw">while</span> <span class="ruby-constant">Pid</span>.<span class="ruby-identifier">running?</span>(<span class="ruby-identifier">pid</span>)
235
- 123: <span class="ruby-identifier">sleep</span> <span class="ruby-value">0</span><span class="ruby-value">.1</span>
236
- 124: <span class="ruby-keyword kw">end</span>
237
- 125: <span class="ruby-keyword kw">rescue</span> <span class="ruby-operator">::</span><span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
238
- 126: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{e} #{@pid.pid}&quot;</span>
239
- 127: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;deleting pid-file.&quot;</span>
240
- 128: <span class="ruby-keyword kw">end</span>
241
- 129:
242
- 130: <span class="ruby-comment cmt"># We try to remove the pid-files by ourselves, in case the application</span>
243
- 131: <span class="ruby-comment cmt"># didn't clean it up.</span>
244
- 132: <span class="ruby-keyword kw">begin</span>; <span class="ruby-ivar">@pid</span>.<span class="ruby-identifier">cleanup</span>; <span class="ruby-keyword kw">rescue</span> <span class="ruby-operator">::</span><span class="ruby-constant">Exception</span>; <span class="ruby-keyword kw">end</span>
245
- 133: <span class="ruby-keyword kw">end</span>
246
- </pre>
247
- </div>
248
- </div>
249
- </div>
250
-
251
-
252
- </div>
253
-
254
-
255
- </div>
256
-
257
-
258
- <div id="validator-badges">
259
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
260
- </div>
261
-
262
- </body>
263
- </html>