rbatch 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.ja.md +14 -5
- data/README.md +164 -154
- data/bin/rbatch-init +21 -13
- data/doc/RBatch/Cmd.html +300 -316
- data/doc/RBatch/CmdException.html +146 -141
- data/doc/RBatch/CmdResult.html +467 -470
- data/doc/RBatch/Config.html +392 -433
- data/doc/RBatch/Controller.html +374 -0
- data/doc/RBatch/DoubleRunCheckException.html +146 -141
- data/doc/RBatch/DoubleRunChecker.html +258 -256
- data/doc/RBatch/Journal.html +332 -0
- data/doc/RBatch/Log.html +636 -805
- data/doc/RBatch/LogException.html +164 -0
- data/doc/RBatch/RBatch/RBatch/ConfigException.html +164 -0
- data/doc/RBatch/RBatch/RBatch.html +163 -0
- data/doc/RBatch/RBatch/VariablesException.html +164 -0
- data/doc/RBatch/RBatch.html +165 -0
- data/doc/RBatch/RunConf/Exception.html +146 -141
- data/doc/RBatch/RunConf.html +478 -532
- data/doc/RBatch/Variables.html +437 -0
- data/doc/RBatch.html +388 -862
- data/doc/created.rid +11 -9
- data/doc/index.html +178 -184
- data/doc/js/darkfish.js +9 -7
- data/doc/lib/rbatch/cmd_rb.html +46 -44
- data/doc/lib/rbatch/config_rb.html +42 -42
- data/doc/lib/rbatch/controller_rb.html +66 -0
- data/doc/lib/rbatch/double_run_checker_rb.html +42 -42
- data/doc/lib/rbatch/journal_rb.html +52 -0
- data/doc/lib/rbatch/log_rb.html +46 -46
- data/doc/lib/rbatch/run_conf_rb.html +42 -42
- data/doc/lib/rbatch/variables_rb.html +54 -0
- data/doc/lib/rbatch/version_rb.html +38 -38
- data/doc/lib/rbatch_rb.html +40 -52
- data/doc/rdoc.css +365 -308
- data/lib/rbatch/cmd.rb +15 -58
- data/lib/rbatch/config.rb +7 -7
- data/lib/rbatch/controller.rb +37 -61
- data/lib/rbatch/double_run_checker.rb +0 -0
- data/lib/rbatch/journal.rb +40 -0
- data/lib/rbatch/log.rb +71 -129
- data/lib/rbatch/run_conf.rb +13 -24
- data/lib/rbatch/variables.rb +82 -0
- data/lib/rbatch/version.rb +1 -1
- data/lib/rbatch.rb +7 -36
- data/sample/.rbatchrc +41 -7
- data/spec/01_rbach_spec.rb +99 -0
- data/spec/{cmd_spec.rb → rbatch/cmd_spec.rb} +40 -43
- data/spec/rbatch/config_spec.rb +67 -0
- data/spec/rbatch/controller_spec.rb +18 -0
- data/spec/{double_run_checker_spec.rb → rbatch/double_run_checker_spec.rb} +3 -0
- data/spec/rbatch/journal_spec.rb +29 -0
- data/spec/rbatch/log_spec.rb +350 -0
- data/spec/{run_conf_spec.rb → rbatch/run_conf_spec.rb} +13 -5
- data/spec/rbatch/variables_spec.rb +68 -0
- data/spec/spec_helper.rb +4 -5
- metadata +33 -17
- data/lib/rbatch/common_config.rb +0 -0
- data/spec/common_config_spec.rb +0 -85
- data/spec/config_spec.rb +0 -79
- data/spec/log_spec.rb +0 -430
- data/spec/rbatch_spec.rb +0 -22
data/doc/RBatch/Cmd.html
CHANGED
@@ -1,336 +1,320 @@
|
|
1
|
-
<?xml version="1.0" encoding="
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
-
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
4
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
5
|
<head>
|
6
|
-
|
6
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
7
7
|
|
8
|
-
|
8
|
+
<title>Class: RBatch::Cmd</title>
|
9
9
|
|
10
|
-
|
10
|
+
<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<script src="../js/quicksearch.js" type="text/javascript"
|
17
|
-
charset="utf-8"></script>
|
18
|
-
<script src="../js/darkfish.js" type="text/javascript"
|
19
|
-
charset="utf-8"></script>
|
12
|
+
<script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
20
16
|
|
21
17
|
</head>
|
22
|
-
<body class="class">
|
18
|
+
<body id="top" class="class">
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
<div id="metadata">
|
21
|
+
<div id="home-metadata">
|
22
|
+
<div id="home-section" class="section">
|
27
23
|
<h3 class="section-header">
|
28
24
|
<a href="../index.html">Home</a>
|
29
25
|
<a href="../index.html#classes">Classes</a>
|
30
26
|
<a href="../index.html#methods">Methods</a>
|
31
27
|
</h3>
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
</
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div id="file-metadata">
|
32
|
+
<div id="file-list-section" class="section">
|
33
|
+
<h3 class="section-header">In Files</h3>
|
34
|
+
<div class="section-body">
|
35
|
+
<ul>
|
36
|
+
|
37
|
+
<li><a href="../lib/rbatch/cmd_rb.html?TB_iframe=true&height=550&width=785"
|
38
|
+
class="thickbox" title="lib/rbatch/cmd.rb">lib/rbatch/cmd.rb</a></li>
|
39
|
+
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div id="class-metadata">
|
48
|
+
|
49
|
+
<!-- Parent Class -->
|
50
|
+
<div id="parent-class-section" class="section">
|
51
|
+
<h3 class="section-header">Parent</h3>
|
52
|
+
|
53
|
+
<p class="link">Object</p>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Method Quickref -->
|
64
|
+
<div id="method-list-section" class="section">
|
65
|
+
<h3 class="section-header">Methods</h3>
|
66
|
+
<ul class="link-list">
|
67
|
+
|
68
|
+
<li><a href="#method-c-def_vars-3D">::def_vars=</a></li>
|
69
|
+
|
70
|
+
<li><a href="#method-c-new">::new</a></li>
|
71
|
+
|
72
|
+
<li><a href="#method-i-run">#run</a></li>
|
73
|
+
|
74
|
+
</ul>
|
75
|
+
</div>
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<div id="project-metadata">
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<div id="classindex-section" class="section project-section">
|
86
|
+
<h3 class="section-header">Class/Module Index
|
87
|
+
<span class="search-toggle"><img src="../images/find.png"
|
88
|
+
height="16" width="16" alt="[+]"
|
89
|
+
title="show/hide quicksearch" /></span></h3>
|
90
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
91
|
+
<fieldset>
|
92
|
+
<legend>Quicksearch</legend>
|
93
|
+
<input type="text" name="quicksearch" value=""
|
94
|
+
class="quicksearch-field" />
|
95
|
+
</fieldset>
|
96
|
+
</form>
|
97
|
+
|
98
|
+
<ul class="link-list">
|
99
|
+
|
100
|
+
<li><a href="../RBatch.html">RBatch</a></li>
|
101
|
+
|
102
|
+
<li><a href="../RBatch/Cmd.html">RBatch::Cmd</a></li>
|
103
|
+
|
104
|
+
<li><a href="../RBatch/CmdException.html">RBatch::CmdException</a></li>
|
105
|
+
|
106
|
+
<li><a href="../RBatch/CmdResult.html">RBatch::CmdResult</a></li>
|
107
|
+
|
108
|
+
<li><a href="../RBatch/Config.html">RBatch::Config</a></li>
|
109
|
+
|
110
|
+
<li><a href="../RBatch/Controller.html">RBatch::Controller</a></li>
|
111
|
+
|
112
|
+
<li><a href="../RBatch/DoubleRunCheckException.html">RBatch::DoubleRunCheckException</a></li>
|
113
|
+
|
114
|
+
<li><a href="../RBatch/DoubleRunChecker.html">RBatch::DoubleRunChecker</a></li>
|
115
|
+
|
116
|
+
<li><a href="../RBatch/Journal.html">RBatch::Journal</a></li>
|
117
|
+
|
118
|
+
<li><a href="../RBatch/Log.html">RBatch::Log</a></li>
|
119
|
+
|
120
|
+
<li><a href="../RBatch/LogException.html">RBatch::LogException</a></li>
|
121
|
+
|
122
|
+
<li><a href="../RBatch/RBatch.html">RBatch::RBatch</a></li>
|
123
|
+
|
124
|
+
<li><a href="../RBatch/RBatch/RBatch.html">RBatch::RBatch::RBatch</a></li>
|
125
|
+
|
126
|
+
<li><a href="../RBatch/RBatch/RBatch/ConfigException.html">RBatch::RBatch::RBatch::ConfigException</a></li>
|
127
|
+
|
128
|
+
<li><a href="../RBatch/RBatch/VariablesException.html">RBatch::RBatch::VariablesException</a></li>
|
129
|
+
|
130
|
+
<li><a href="../RBatch/RunConf.html">RBatch::RunConf</a></li>
|
131
|
+
|
132
|
+
<li><a href="../RBatch/RunConf/Exception.html">RBatch::RunConf::Exception</a></li>
|
133
|
+
|
134
|
+
<li><a href="../RBatch/Variables.html">RBatch::Variables</a></li>
|
135
|
+
|
136
|
+
</ul>
|
137
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
138
|
+
</div>
|
139
|
+
|
140
|
+
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
<div id="documentation">
|
145
|
+
<h1 class="class">RBatch::Cmd</h1>
|
146
|
+
|
147
|
+
<div id="description" class="description">
|
148
|
+
|
149
|
+
</div><!-- description -->
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
<!-- Methods -->
|
164
|
+
|
165
|
+
<div id="public-class-method-details" class="method-section section">
|
166
|
+
<h3 class="section-header">Public Class Methods</h3>
|
167
|
+
|
168
|
+
|
169
|
+
<div id="def_vars-3D-method" class="method-detail ">
|
170
|
+
<a name="method-c-def_vars-3D"></a>
|
171
|
+
|
172
|
+
|
173
|
+
<div class="method-heading">
|
174
|
+
<span class="method-name">def_vars=</span><span
|
175
|
+
class="method-args">(a)</span>
|
176
|
+
<span class="method-click-advice">click to toggle source</span>
|
177
|
+
</div>
|
178
|
+
|
179
|
+
|
180
|
+
<div class="method-description">
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
<div class="method-source-code" id="def_vars-3D-source">
|
147
187
|
<pre>
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
<!-- Methods -->
|
179
|
-
|
180
|
-
<div id="public-class-method-details" class="method-section section">
|
181
|
-
<h3 class="section-header">Public Class Methods</h3>
|
182
|
-
|
183
|
-
|
184
|
-
<div id="new-method" class="method-detail ">
|
185
|
-
<a name="method-c-new"></a>
|
186
|
-
|
187
|
-
<div class="method-heading">
|
188
|
-
|
189
|
-
<span class="method-name">new</span><span
|
190
|
-
class="method-args">(cmd_str,opt = nil)</span>
|
191
|
-
<span class="method-click-advice">click to toggle source</span>
|
192
|
-
|
193
|
-
</div>
|
194
|
-
|
195
|
-
<div class="method-description">
|
196
|
-
|
197
|
-
<p>
|
198
|
-
<a href="Cmd.html">Cmd</a> instance
|
199
|
-
</p>
|
200
|
-
<h4>Params</h4>
|
201
|
-
<p>
|
202
|
-
<tt>cmd_str</tt> = Command string such as “ls -l” <tt>opt</tt>
|
203
|
-
= Option hash object.
|
204
|
-
</p>
|
205
|
-
<ul>
|
206
|
-
<li><p>
|
207
|
-
<tt>:raise</tt> (Boolean) = If command exit status is not 0, raise
|
208
|
-
exception. Default is false.
|
209
|
-
</p>
|
210
|
-
</li>
|
211
|
-
<li><p>
|
212
|
-
<tt>:timeout</tt> (Integer) = If command timeout , raise exception and kill
|
213
|
-
process. Default is 0 sec ( 0 means disable) .
|
214
|
-
</p>
|
215
|
-
</li>
|
216
|
-
</ul>
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
<div class="method-source-code"
|
221
|
-
id="new-source">
|
188
|
+
<span class="ruby-comment"># File lib/rbatch/cmd.rb, line 9</span>
|
189
|
+
<span class="ruby-keyword">def</span> <span class="ruby-constant">Cmd</span>.<span class="ruby-identifier">def_vars=</span>(<span class="ruby-identifier">a</span>) ; <span class="ruby-identifier">@@def_vars</span>=<span class="ruby-identifier">a</span> ; <span class="ruby-keyword">end</span></pre>
|
190
|
+
</div><!-- def_vars-3D-source -->
|
191
|
+
|
192
|
+
</div>
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
</div><!-- def_vars-3D-method -->
|
198
|
+
|
199
|
+
|
200
|
+
<div id="new-method" class="method-detail ">
|
201
|
+
<a name="method-c-new"></a>
|
202
|
+
|
203
|
+
|
204
|
+
<div class="method-heading">
|
205
|
+
<span class="method-name">new</span><span
|
206
|
+
class="method-args">(cmd_str,opt = nil)</span>
|
207
|
+
<span class="method-click-advice">click to toggle source</span>
|
208
|
+
</div>
|
209
|
+
|
210
|
+
|
211
|
+
<div class="method-description">
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
<div class="method-source-code" id="new-source">
|
222
218
|
<pre>
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
<
|
271
|
-
instance of <a href="CmdResult.html">RBatch::CmdResult</a>
|
272
|
-
</p>
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
<div class="method-source-code"
|
277
|
-
id="run-source">
|
219
|
+
<span class="ruby-comment"># File lib/rbatch/cmd.rb, line 13</span>
|
220
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">cmd_str</span>,<span class="ruby-identifier">opt</span> = <span class="ruby-keyword">nil</span>)
|
221
|
+
<span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-string">"Command string is nil"</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">cmd_str</span>.<span class="ruby-identifier">nil?</span>
|
222
|
+
<span class="ruby-ivar">@cmd_str</span> = <span class="ruby-identifier">cmd_str</span>
|
223
|
+
<span class="ruby-ivar">@vars</span> = <span class="ruby-identifier">@@def_vars</span>.<span class="ruby-identifier">clone</span>
|
224
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">nil?</span>
|
225
|
+
<span class="ruby-comment"># change opt key from "hoge" to "log_hoge"</span>
|
226
|
+
<span class="ruby-identifier">tmp</span> = {}
|
227
|
+
<span class="ruby-identifier">opt</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
228
|
+
<span class="ruby-identifier">tmp</span>[(<span class="ruby-string">"cmd_"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">opt</span>[<span class="ruby-identifier">key</span>]
|
229
|
+
<span class="ruby-keyword">end</span>
|
230
|
+
<span class="ruby-ivar">@vars</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">tmp</span>)
|
231
|
+
<span class="ruby-keyword">end</span>
|
232
|
+
<span class="ruby-keyword">end</span></pre>
|
233
|
+
</div><!-- new-source -->
|
234
|
+
|
235
|
+
</div>
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
</div><!-- new-method -->
|
241
|
+
|
242
|
+
|
243
|
+
</div><!-- public-class-method-details -->
|
244
|
+
|
245
|
+
<div id="public-instance-method-details" class="method-section section">
|
246
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
247
|
+
|
248
|
+
|
249
|
+
<div id="run-method" class="method-detail ">
|
250
|
+
<a name="method-i-run"></a>
|
251
|
+
|
252
|
+
|
253
|
+
<div class="method-heading">
|
254
|
+
<span class="method-name">run</span><span
|
255
|
+
class="method-args">()</span>
|
256
|
+
<span class="method-click-advice">click to toggle source</span>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
|
260
|
+
<div class="method-description">
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
<div class="method-source-code" id="run-source">
|
278
267
|
<pre>
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
<div id="validator-badges">
|
330
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
331
|
-
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
332
|
-
Rdoc Generator</a> 1.1.6</small>.</p>
|
333
|
-
</div>
|
268
|
+
<span class="ruby-comment"># File lib/rbatch/cmd.rb, line 27</span>
|
269
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">run</span>()
|
270
|
+
<span class="ruby-identifier">stdout_file</span> = <span class="ruby-constant">Tempfile</span><span class="ruby-operator">::</span><span class="ruby-identifier">new</span>(<span class="ruby-string">"rbatch_tmpout"</span>,<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>)
|
271
|
+
<span class="ruby-identifier">stderr_file</span> = <span class="ruby-constant">Tempfile</span><span class="ruby-operator">::</span><span class="ruby-identifier">new</span>(<span class="ruby-string">"rbatch_tmperr"</span>,<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>)
|
272
|
+
<span class="ruby-identifier">pid</span> = <span class="ruby-identifier">spawn</span>(<span class="ruby-ivar">@cmd_str</span>,<span class="ruby-value">:out</span> =<span class="ruby-operator">></span> [<span class="ruby-identifier">stdout_file</span>,<span class="ruby-string">"w"</span>],<span class="ruby-value">:err</span> =<span class="ruby-operator">></span> [<span class="ruby-identifier">stderr_file</span>,<span class="ruby-string">"w"</span>])
|
273
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-keyword">nil</span>
|
274
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:cmd_timeout</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
|
275
|
+
<span class="ruby-keyword">begin</span>
|
276
|
+
<span class="ruby-identifier">timeout</span>(<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:cmd_timeout</span>]) <span class="ruby-keyword">do</span>
|
277
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid2</span>(<span class="ruby-identifier">pid</span>)[<span class="ruby-value">1</span>] <span class="ruby-operator">>></span> <span class="ruby-value">8</span>
|
278
|
+
<span class="ruby-keyword">end</span>
|
279
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
280
|
+
<span class="ruby-keyword">begin</span>
|
281
|
+
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-string">'SIGINT'</span>, <span class="ruby-identifier">pid</span>)
|
282
|
+
<span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-node">"Run time of command \"#{@cmd_str}\" is over #{@vars[:cmd_timeout].to_s} sec. Success to kill process : PID=#{pid}"</span> )
|
283
|
+
<span class="ruby-keyword">rescue</span>
|
284
|
+
<span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-node">"Run time of command \"#{@cmd_str}\" is over #{@vars[:cmd_timeout].to_s} sec. Fail to kill process : PID=#{pid}"</span> )
|
285
|
+
<span class="ruby-keyword">end</span>
|
286
|
+
<span class="ruby-keyword">end</span>
|
287
|
+
<span class="ruby-keyword">else</span>
|
288
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid2</span>(<span class="ruby-identifier">pid</span>)[<span class="ruby-value">1</span>] <span class="ruby-operator">>></span> <span class="ruby-value">8</span>
|
289
|
+
<span class="ruby-keyword">end</span>
|
290
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-constant">RBatch</span><span class="ruby-operator">::</span><span class="ruby-constant">CmdResult</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">stdout_file</span>,<span class="ruby-identifier">stderr_file</span>,<span class="ruby-identifier">status</span>,<span class="ruby-ivar">@cmd_str</span>)
|
291
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:cmd_raise</span>] <span class="ruby-operator">&&</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
|
292
|
+
<span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-string">"Command exit status is not 0. result: "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">to_s</span>)
|
293
|
+
<span class="ruby-keyword">end</span>
|
294
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">result</span>
|
295
|
+
<span class="ruby-keyword">end</span></pre>
|
296
|
+
</div><!-- run-source -->
|
297
|
+
|
298
|
+
</div>
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
</div><!-- run-method -->
|
304
|
+
|
305
|
+
|
306
|
+
</div><!-- public-instance-method-details -->
|
307
|
+
|
308
|
+
</div><!-- 5Buntitled-5D -->
|
309
|
+
|
310
|
+
|
311
|
+
</div><!-- documentation -->
|
312
|
+
|
313
|
+
<div id="validator-badges">
|
314
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
315
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
316
|
+
Rdoc Generator</a> 2</small>.</p>
|
317
|
+
</div>
|
334
318
|
|
335
319
|
</body>
|
336
320
|
</html>
|