rbatch 1.13.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/CHANGELOG +15 -0
  2. data/README.ja.md +81 -49
  3. data/README.md +88 -63
  4. data/Rakefile +2 -31
  5. data/bin/rbatch-init +57 -32
  6. data/{rdocs → doc}/RBatch/Cmd.html +66 -59
  7. data/{rdocs → doc}/RBatch/CmdException.html +9 -3
  8. data/{rdocs → doc}/RBatch/CmdResult.html +40 -34
  9. data/{rdocs → doc}/RBatch/CommonConfig/Exception.html +9 -3
  10. data/{rdocs → doc}/RBatch/CommonConfig.html +22 -17
  11. data/{rdocs → doc}/RBatch/Config/Exception.html +9 -3
  12. data/{rdocs → doc}/RBatch/Config.html +21 -16
  13. data/{rdocs/RBatchException.html → doc/RBatch/DoubleRunCheckException.html} +33 -30
  14. data/doc/RBatch/DoubleRunChecker.html +277 -0
  15. data/{rdocs → doc}/RBatch/Log.html +134 -138
  16. data/doc/RBatch/RunConf/Exception.html +159 -0
  17. data/doc/RBatch/RunConf.html +557 -0
  18. data/doc/RBatch.html +655 -0
  19. data/doc/created.rid +9 -0
  20. data/{rdocs → doc}/index.html +46 -20
  21. data/{rdocs → doc}/lib/rbatch/cmd_rb.html +4 -2
  22. data/{rdocs → doc}/lib/rbatch/common_config_rb.html +2 -2
  23. data/{rdocs → doc}/lib/rbatch/config_rb.html +2 -2
  24. data/doc/lib/rbatch/double_run_checker_rb.html +56 -0
  25. data/{rdocs → doc}/lib/rbatch/log_rb.html +2 -2
  26. data/doc/lib/rbatch/run_conf_rb.html +56 -0
  27. data/{rdocs → doc}/lib/rbatch/version_rb.html +2 -2
  28. data/{rdocs → doc}/lib/rbatch_rb.html +7 -3
  29. data/lib/rbatch/cmd.rb +20 -23
  30. data/lib/rbatch/common_config.rb +2 -3
  31. data/lib/rbatch/config.rb +1 -2
  32. data/lib/rbatch/double_run_checker.rb +24 -0
  33. data/lib/rbatch/log.rb +37 -59
  34. data/lib/rbatch/run_conf.rb +109 -0
  35. data/lib/rbatch/version.rb +1 -1
  36. data/lib/rbatch.rb +37 -56
  37. data/spec/{cmd_test.spec → cmd_spec.rb} +6 -6
  38. data/spec/common_config_spec.rb +54 -0
  39. data/spec/{config_test.spec → config_spec.rb} +2 -1
  40. data/spec/double_run_checker_spec.rb +10 -0
  41. data/spec/{log_test.spec → log_spec.rb} +22 -22
  42. data/spec/rbatch_spec.rb +24 -0
  43. data/spec/run_conf_spec.rb +85 -0
  44. metadata +66 -65
  45. data/rdocs/RBatch.html +0 -713
  46. data/rdocs/created.rid +0 -7
  47. data/spec/rbatch_test.spec +0 -25
  48. data/test/cases/test_cmd.rb +0 -134
  49. data/test/cases/test_common_config.rb +0 -41
  50. data/test/cases/test_config.rb +0 -41
  51. data/test/cases/test_log.rb +0 -613
  52. data/test/mocks/PrintArgs.exe +0 -0
  53. data/test/mocks/win_cmd.exe +0 -0
  54. /data/{rdocs → doc}/images/brick.png +0 -0
  55. /data/{rdocs → doc}/images/brick_link.png +0 -0
  56. /data/{rdocs → doc}/images/bug.png +0 -0
  57. /data/{rdocs → doc}/images/bullet_black.png +0 -0
  58. /data/{rdocs → doc}/images/bullet_toggle_minus.png +0 -0
  59. /data/{rdocs → doc}/images/bullet_toggle_plus.png +0 -0
  60. /data/{rdocs → doc}/images/date.png +0 -0
  61. /data/{rdocs → doc}/images/find.png +0 -0
  62. /data/{rdocs → doc}/images/loadingAnimation.gif +0 -0
  63. /data/{rdocs → doc}/images/macFFBgHack.png +0 -0
  64. /data/{rdocs → doc}/images/package.png +0 -0
  65. /data/{rdocs → doc}/images/page_green.png +0 -0
  66. /data/{rdocs → doc}/images/page_white_text.png +0 -0
  67. /data/{rdocs → doc}/images/page_white_width.png +0 -0
  68. /data/{rdocs → doc}/images/plugin.png +0 -0
  69. /data/{rdocs → doc}/images/ruby.png +0 -0
  70. /data/{rdocs → doc}/images/tag_green.png +0 -0
  71. /data/{rdocs → doc}/images/wrench.png +0 -0
  72. /data/{rdocs → doc}/images/wrench_orange.png +0 -0
  73. /data/{rdocs → doc}/images/zoom.png +0 -0
  74. /data/{rdocs → doc}/js/darkfish.js +0 -0
  75. /data/{rdocs → doc}/js/jquery.js +0 -0
  76. /data/{rdocs → doc}/js/quicksearch.js +0 -0
  77. /data/{rdocs → doc}/js/thickbox-compressed.js +0 -0
  78. /data/{rdocs → doc}/rdoc.css +0 -0
data/bin/rbatch-init CHANGED
@@ -1,36 +1,36 @@
1
1
  #!/usr/local/bin/ruby
2
2
 
3
3
  contents = {}
4
- contents["bin/hello_world.rb"] = <<EOF
5
- require 'rbatch'
6
-
7
- RBatch::Log.new{|log|
8
- log.info("hello world")
9
- log.info("config value: " + RBatch::config["key1"])
10
- result = RBatch.cmd("ls")
11
- log.info(result)
12
- }
13
-
14
- EOF
15
-
16
- contents["conf/hello_world.yaml"] = <<EOF
17
- key1 : value1
18
- EOF
19
4
 
20
- contents["conf/rbatch.yaml"] = <<EOF
21
- # RBatch Common Config
5
+ contents[".rbatchrc"] = <<EOF
6
+ # RBatch Run-Conf (.rbatchrc)
22
7
  #
23
- # This file format is YAML.
8
+ # This format is YAML.
24
9
  #
25
10
 
26
11
  # -------------------
27
12
  # Global setting
28
13
  # -------------------
29
14
 
15
+ # Conf Directory
16
+ #
17
+ # Default is "<home>/conf"
18
+ #
19
+ # <home> is replaced to ${RB_HOME}
20
+ #
21
+ #conf_dir: <home>/config
22
+ #conf_dir: /etc/rbatch/
23
+
24
+ # Common config file name
25
+ #
26
+ # Default is "common.yaml"
27
+ #
28
+ #common_conf_name: share.yaml
29
+
30
30
  # Forbit Script Double Run
31
31
  #
32
32
  # Default is false.
33
- # If this option is true, two same script cannot start at the same time.
33
+ # If this option is true, two same name scripts cannot run at the same time.
34
34
  #
35
35
  #forbid_double_run: true
36
36
  #forbid_double_run: false
@@ -47,29 +47,37 @@ contents["conf/rbatch.yaml"] = <<EOF
47
47
  #cmd_raise : true
48
48
  #cmd_raise : false
49
49
 
50
+ # Command Timeout
51
+ #
52
+ # Default is 0 [sec].
53
+ #
54
+ #cmd_timeout: 5
50
55
 
51
56
  # -------------------
52
57
  # Log setting
53
58
  # -------------------
54
59
 
60
+ # Log Directory
61
+ #
62
+ # Default is "<home>/log"
63
+ #
64
+ # <home> is replaced to ${RB_HOME}
65
+ #
66
+ #log_dir: <home>/rb_log
67
+ #log_dir: /var/log/rbatch/
68
+
55
69
  # Log File Name
56
70
  #
57
71
  # Default is "<date>_<time>_<prog>.log".
58
72
  # Reservation words are follows.
59
- # <data> --> Replace to YYYYMMDD date string
60
- # <time> --> Replace to HHMMSS time string
61
- # <prog> --> Replace to Program file base name (except extention).
62
- # <host> --> Replace to Hostname.
73
+ # <data> is replaced to YYYYMMDD date string
74
+ # <time> is replaced to HHMMSS time string
75
+ # <prog> is replaced to Program file base name (except extention).
76
+ # <host> is replaced to Hostname.
63
77
  #
64
78
  #log_name : "<date>_<time>_<prog>.log"
65
79
  #log_name : "<date>_<prog>.log"
66
80
 
67
- # Log Output Directory
68
- #
69
- # Default is "(Script path)/../log".
70
- #
71
- #log_dir : "/tmp/log"
72
-
73
81
  # Append log or not
74
82
  #
75
83
  # Default is ture.
@@ -88,7 +96,7 @@ contents["conf/rbatch.yaml"] = <<EOF
88
96
  #log_level : "error"
89
97
  #log_level : "fatal"
90
98
 
91
- # Print log-string both file and STDOUT
99
+ # Print log string both file and STDOUT
92
100
  #
93
101
  # Default is false.
94
102
  #
@@ -118,7 +126,7 @@ contents["conf/rbatch.yaml"] = <<EOF
118
126
  #
119
127
  #log_send_mail : true
120
128
 
121
- # Send mail parameters
129
+ # Mail parameters
122
130
  #
123
131
  #log_mail_to : "xxx@sample.com"
124
132
  #log_mail_from : "xxx@sample.com"
@@ -127,6 +135,23 @@ contents["conf/rbatch.yaml"] = <<EOF
127
135
 
128
136
  EOF
129
137
 
138
+ contents["bin/hello_world.rb"] = <<EOF
139
+ require 'rbatch'
140
+
141
+ RBatch::Log.new{|log|
142
+ log.info("hello world")
143
+ log.info("config value: " + RBatch::config["key1"])
144
+ result = RBatch.cmd("ls")
145
+ log.info(result)
146
+ }
147
+
148
+ EOF
149
+
150
+ contents["conf/hello_world.yaml"] = <<EOF
151
+ key1 : value1
152
+ EOF
153
+
154
+
130
155
  require 'fileutils'
131
156
  ["bin","conf","log"].each do | dir |
132
157
  if ! Dir.exists?(dir)
@@ -136,7 +161,7 @@ require 'fileutils'
136
161
  puts "exist ./" + dir + " (not create)"
137
162
  end
138
163
  end
139
- ["bin/hello_world.rb","conf/hello_world.yaml","conf/rbatch.yaml"].each do | file |
164
+ ["bin/hello_world.rb","conf/hello_world.yaml",".rbatchrc"].each do | file |
140
165
  if ! File.exists?(file)
141
166
  File.open(file, "w") { |f| f.puts contents[file] }
142
167
  puts "create ./" + file
@@ -1,9 +1,9 @@
1
- <?xml version="1.0" encoding="harset=UTF-8 "?>
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
- <meta content="text/html; charset=harset=UTF-8 " http-equiv="Content-Type" />
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
7
 
8
8
  <title>Class: RBatch::Cmd</title>
9
9
 
@@ -116,9 +116,15 @@
116
116
 
117
117
  <li><a href="../RBatch/Config/Exception.html">RBatch::Config::Exception</a></li>
118
118
 
119
+ <li><a href="../RBatch/DoubleRunCheckException.html">RBatch::DoubleRunCheckException</a></li>
120
+
121
+ <li><a href="../RBatch/DoubleRunChecker.html">RBatch::DoubleRunChecker</a></li>
122
+
119
123
  <li><a href="../RBatch/Log.html">RBatch::Log</a></li>
120
124
 
121
- <li><a href="../RBatchException.html">RBatchException</a></li>
125
+ <li><a href="../RBatch/RunConf.html">RBatch::RunConf</a></li>
126
+
127
+ <li><a href="../RBatch/RunConf/Exception.html">RBatch::RunConf::Exception</a></li>
122
128
 
123
129
  </ul>
124
130
  <div id="no-class-search-results" style="display: none;">No matching classes.</div>
@@ -140,26 +146,25 @@ This module is a wrapper of Kernel#spawn.
140
146
  </p>
141
147
  <pre>
142
148
  * Arguments(cmd_params) are inputed to Kernel#spawn directly and run command.
143
- * Command's stdout and stderr is written to tmp file.
144
- * If Platform is &quot;mswin&quot; or &quot;mingw&quot; , then temp directory is ENV[&quot;TEMP&quot;]
145
- * If Platform is &quot;linux&quot; or &quot;cygwin&quot; , then temp directory is &quot;/tmp/&quot;
146
149
  * Return an object of RBatch::CmdResult which includes stdout, stderr, and exit status.
147
150
 
148
151
  ==== Sample 1
149
152
  require 'rbatch'
150
- cmd = RBatch::Cmd(&quot;ls&quot;)
151
- r = cmd.run
152
- p r.stdout
153
+ result = RBatch::cmd(&quot;ls&quot;)
154
+ p result.stdout
153
155
  =&gt; &quot;fileA\nfileB\n&quot;
154
156
 
155
- ==== Sample 2 ( Use option)
156
- cmd = RBatch::Cmd(&quot;ls&quot;, {:verbose =&gt; true})
157
- r = cmd.run
157
+ ==== Sample 2 (use option)
158
+ require 'rbatch'
159
+ result = RBatch::cmd(&quot;ls&quot;,{:timeout =&gt; 1})
160
+ p result.stdout
161
+ =&gt; &quot;fileA\nfileB\n&quot;
158
162
 
159
- ==== Sample 3 ( Use alias)
163
+ ==== Sample 3 (use instance)
160
164
  require 'rbatch'
161
- r = RBatch::cmd(&quot;ls&quot;)
162
- p r.stdout
165
+ cmd = RBatch::Cmd.new(&quot;ls&quot;)
166
+ result = cmd.run
167
+ p result.stdout
163
168
  =&gt; &quot;fileA\nfileB\n&quot;</pre>
164
169
 
165
170
  </div>
@@ -194,8 +199,8 @@ This module is a wrapper of Kernel#spawn.
194
199
  </p>
195
200
  <h4>Params</h4>
196
201
  <p>
197
- <tt>cmd_str</tt> = Command string. Such ad &#8220;ls -l&#8221; <tt>opt</tt>
198
- = Option hash object. Hash keys is follows.
202
+ <tt>cmd_str</tt> = Command string such as &#8220;ls -l&#8221; <tt>opt</tt>
203
+ = Option hash object.
199
204
  </p>
200
205
  <ul>
201
206
  <li><p>
@@ -204,8 +209,8 @@ exception. Default is false.
204
209
  </p>
205
210
  </li>
206
211
  <li><p>
207
- <tt>:timeout</tt> (Integer) = If command timeout , raise exception. Default
208
- is 0 sec ( 0 means disable) .
212
+ <tt>:timeout</tt> (Integer) = If command timeout , raise exception and kill
213
+ process. Default is 0 sec ( 0 means disable) .
209
214
  </p>
210
215
  </li>
211
216
  </ul>
@@ -215,24 +220,20 @@ is 0 sec ( 0 means disable) .
215
220
  <div class="method-source-code"
216
221
  id="new-source">
217
222
  <pre>
218
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 48</span>
219
- 48: <span class="ruby-keyword kw">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 kw">nil</span>)
220
- 49: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-value str">&quot;Command string is nil&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cmd_str</span>.<span class="ruby-identifier">nil?</span>
221
- 50: <span class="ruby-ivar">@cmd_str</span> = <span class="ruby-identifier">cmd_str</span>
222
- 51: <span class="ruby-comment cmt"># parse option</span>
223
- 52: <span class="ruby-ivar">@opt</span> = <span class="ruby-identifier">@@def_opt</span>.<span class="ruby-identifier">clone</span>
224
- 53: <span class="ruby-identifier">@@def_opt</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
225
- 54: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opt</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">opt</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
226
- 55: <span class="ruby-comment cmt"># use argument</span>
227
- 56: <span class="ruby-ivar">@opt</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">opt</span>[<span class="ruby-identifier">key</span>]
228
- 57: <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">rbatch_config</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">rbatch_config</span>[<span class="ruby-value str">&quot;cmd_&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
229
- 58: <span class="ruby-comment cmt"># use config</span>
230
- 59: <span class="ruby-ivar">@opt</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">rbatch_config</span>[<span class="ruby-value str">&quot;cmd_&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>]
231
- 60: <span class="ruby-keyword kw">else</span>
232
- 61: <span class="ruby-comment cmt"># use default</span>
233
- 62: <span class="ruby-keyword kw">end</span>
234
- 63: <span class="ruby-keyword kw">end</span>
235
- 64: <span class="ruby-keyword kw">end</span></pre>
223
+ <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 44</span>
224
+ 44: <span class="ruby-keyword kw">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 kw">nil</span>)
225
+ 45: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-value str">&quot;Command string is nil&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cmd_str</span>.<span class="ruby-identifier">nil?</span>
226
+ 46: <span class="ruby-ivar">@cmd_str</span> = <span class="ruby-identifier">cmd_str</span>
227
+ 47: <span class="ruby-identifier">tmp</span> = {}
228
+ 48: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">nil?</span>
229
+ 49: <span class="ruby-ivar">@opt</span>=<span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">run_conf</span>.<span class="ruby-identifier">clone</span>
230
+ 50: <span class="ruby-keyword kw">else</span>
231
+ 51: <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
232
+ 52: <span class="ruby-identifier">tmp</span>[(<span class="ruby-value str">&quot;cmd_&quot;</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>]
233
+ 53: <span class="ruby-keyword kw">end</span>
234
+ 54: <span class="ruby-ivar">@opt</span>=<span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">run_conf</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">tmp</span>)
235
+ 55: <span class="ruby-keyword kw">end</span>
236
+ 56: <span class="ruby-keyword kw">end</span></pre>
236
237
  </div>
237
238
 
238
239
  </div>
@@ -275,28 +276,34 @@ instance of <a href="CmdResult.html">RBatch::CmdResult</a>
275
276
  <div class="method-source-code"
276
277
  id="run-source">
277
278
  <pre>
278
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 71</span>
279
- 71: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>()
280
- 72: <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-value str">&quot;rbatch_tmpout&quot;</span>,<span class="ruby-constant">RBatch</span><span class="ruby-operator">::</span><span class="ruby-identifier">tmp_dir</span>)
281
- 73: <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-value str">&quot;rbatch_tmperr&quot;</span>,<span class="ruby-constant">RBatch</span><span class="ruby-operator">::</span><span class="ruby-identifier">tmp_dir</span>)
282
- 74: <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">&gt;</span> [<span class="ruby-identifier">stdout_file</span>,<span class="ruby-value str">&quot;w&quot;</span>],<span class="ruby-value">:err</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-identifier">stderr_file</span>,<span class="ruby-value str">&quot;w&quot;</span>])
283
- 75: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:timeout</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
284
- 76: <span class="ruby-identifier">timeout</span>(<span class="ruby-ivar">@opt</span>[<span class="ruby-value">:timeout</span>]) <span class="ruby-keyword kw">do</span>
285
- 77: <span class="ruby-keyword kw">begin</span>
286
- 78: <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">&gt;&gt;</span> <span class="ruby-value">8</span>
287
- 79: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
288
- 80: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-value str">&quot;Command timeout (over &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:timeout</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; sec)&quot;</span> )
289
- 81: <span class="ruby-keyword kw">end</span>
290
- 82: <span class="ruby-keyword kw">end</span>
291
- 83: <span class="ruby-keyword kw">else</span>
292
- 84: <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">&gt;&gt;</span> <span class="ruby-value">8</span>
293
- 85: <span class="ruby-keyword kw">end</span>
294
- 86: <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>)
295
- 87: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:raise</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
296
- 88: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-value str">&quot;Command exit status is not 0. result: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">to_s</span>)
297
- 89: <span class="ruby-keyword kw">end</span>
298
- 90: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
299
- 91: <span class="ruby-keyword kw">end</span></pre>
279
+ <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 62</span>
280
+ 62: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>()
281
+ 63: <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-value str">&quot;rbatch_tmpout&quot;</span>,<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>)
282
+ 64: <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-value str">&quot;rbatch_tmperr&quot;</span>,<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>)
283
+ 65: <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">&gt;</span> [<span class="ruby-identifier">stdout_file</span>,<span class="ruby-value str">&quot;w&quot;</span>],<span class="ruby-value">:err</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-identifier">stderr_file</span>,<span class="ruby-value str">&quot;w&quot;</span>])
284
+ 66: <span class="ruby-identifier">status</span> = <span class="ruby-keyword kw">nil</span>
285
+ 67: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:cmd_timeout</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
286
+ 68: <span class="ruby-keyword kw">begin</span>
287
+ 69: <span class="ruby-identifier">timeout</span>(<span class="ruby-ivar">@opt</span>[<span class="ruby-value">:cmd_timeout</span>]) <span class="ruby-keyword kw">do</span>
288
+ 70: <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">&gt;&gt;</span> <span class="ruby-value">8</span>
289
+ 71: <span class="ruby-keyword kw">end</span>
290
+ 72: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
291
+ 73: <span class="ruby-keyword kw">begin</span>
292
+ 74: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-value str">'SIGINT'</span>, <span class="ruby-identifier">pid</span>)
293
+ 75: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-node">&quot;Run time of command \&quot;#{@cmd_str}\&quot; is over #{@opt[:cmd_timeout].to_s} sec. Success to kill process : PID=#{pid}&quot;</span> )
294
+ 76: <span class="ruby-keyword kw">rescue</span>
295
+ 77: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-node">&quot;Run time of command \&quot;#{@cmd_str}\&quot; is over #{@opt[:cmd_timeout].to_s} sec. Fail to kill process : PID=#{pid}&quot;</span> )
296
+ 78: <span class="ruby-keyword kw">end</span>
297
+ 79: <span class="ruby-keyword kw">end</span>
298
+ 80: <span class="ruby-keyword kw">else</span>
299
+ 81: <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">&gt;&gt;</span> <span class="ruby-value">8</span>
300
+ 82: <span class="ruby-keyword kw">end</span>
301
+ 83: <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>)
302
+ 84: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:cmd_raise</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
303
+ 85: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-value str">&quot;Command exit status is not 0. result: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">to_s</span>)
304
+ 86: <span class="ruby-keyword kw">end</span>
305
+ 87: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
306
+ 88: <span class="ruby-keyword kw">end</span></pre>
300
307
  </div>
301
308
 
302
309
  </div>
@@ -1,9 +1,9 @@
1
- <?xml version="1.0" encoding="harset=UTF-8 "?>
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
- <meta content="text/html; charset=harset=UTF-8 " http-equiv="Content-Type" />
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
7
 
8
8
  <title>Class: RBatch::CmdException</title>
9
9
 
@@ -105,9 +105,15 @@
105
105
 
106
106
  <li><a href="../RBatch/Config/Exception.html">RBatch::Config::Exception</a></li>
107
107
 
108
+ <li><a href="../RBatch/DoubleRunCheckException.html">RBatch::DoubleRunCheckException</a></li>
109
+
110
+ <li><a href="../RBatch/DoubleRunChecker.html">RBatch::DoubleRunChecker</a></li>
111
+
108
112
  <li><a href="../RBatch/Log.html">RBatch::Log</a></li>
109
113
 
110
- <li><a href="../RBatchException.html">RBatchException</a></li>
114
+ <li><a href="../RBatch/RunConf.html">RBatch::RunConf</a></li>
115
+
116
+ <li><a href="../RBatch/RunConf/Exception.html">RBatch::RunConf::Exception</a></li>
111
117
 
112
118
  </ul>
113
119
  <div id="no-class-search-results" style="display: none;">No matching classes.</div>
@@ -1,9 +1,9 @@
1
- <?xml version="1.0" encoding="harset=UTF-8 "?>
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
- <meta content="text/html; charset=harset=UTF-8 " http-equiv="Content-Type" />
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
7
 
8
8
  <title>Class: RBatch::CmdResult</title>
9
9
 
@@ -130,9 +130,15 @@
130
130
 
131
131
  <li><a href="../RBatch/Config/Exception.html">RBatch::Config::Exception</a></li>
132
132
 
133
+ <li><a href="../RBatch/DoubleRunCheckException.html">RBatch::DoubleRunCheckException</a></li>
134
+
135
+ <li><a href="../RBatch/DoubleRunChecker.html">RBatch::DoubleRunChecker</a></li>
136
+
133
137
  <li><a href="../RBatch/Log.html">RBatch::Log</a></li>
134
138
 
135
- <li><a href="../RBatchException.html">RBatchException</a></li>
139
+ <li><a href="../RBatch/RunConf.html">RBatch::RunConf</a></li>
140
+
141
+ <li><a href="../RBatch/RunConf/Exception.html">RBatch::RunConf::Exception</a></li>
136
142
 
137
143
  </ul>
138
144
  <div id="no-class-search-results" style="display: none;">No matching classes.</div>
@@ -181,13 +187,13 @@
181
187
  <div class="method-source-code"
182
188
  id="new-source">
183
189
  <pre>
184
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 99</span>
185
- 99: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">stdout_file</span>, <span class="ruby-identifier">stderr_file</span>, <span class="ruby-identifier">status</span>, <span class="ruby-identifier">cmd_str</span>)
186
- 100: <span class="ruby-ivar">@stdout_file</span> = <span class="ruby-identifier">stdout_file</span>
187
- 101: <span class="ruby-ivar">@stderr_file</span> = <span class="ruby-identifier">stderr_file</span>
188
- 102: <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">status</span>
189
- 103: <span class="ruby-ivar">@cmd_str</span> = <span class="ruby-identifier">cmd_str</span>
190
- 104: <span class="ruby-keyword kw">end</span></pre>
190
+ <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 96</span>
191
+ 96: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">stdout_file</span>, <span class="ruby-identifier">stderr_file</span>, <span class="ruby-identifier">status</span>, <span class="ruby-identifier">cmd_str</span>)
192
+ 97: <span class="ruby-ivar">@stdout_file</span> = <span class="ruby-identifier">stdout_file</span>
193
+ 98: <span class="ruby-ivar">@stderr_file</span> = <span class="ruby-identifier">stderr_file</span>
194
+ 99: <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">status</span>
195
+ 100: <span class="ruby-ivar">@cmd_str</span> = <span class="ruby-identifier">cmd_str</span>
196
+ 101: <span class="ruby-keyword kw">end</span></pre>
191
197
  </div>
192
198
 
193
199
  </div>
@@ -224,8 +230,8 @@
224
230
  <div class="method-source-code"
225
231
  id="cmd-str-source">
226
232
  <pre>
227
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 108</span>
228
- 108: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_str</span> ; <span class="ruby-ivar">@cmd_str</span> ; <span class="ruby-keyword kw">end</span></pre>
233
+ <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 105</span>
234
+ 105: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_str</span> ; <span class="ruby-ivar">@cmd_str</span> ; <span class="ruby-keyword kw">end</span></pre>
229
235
  </div>
230
236
 
231
237
  </div>
@@ -256,8 +262,8 @@
256
262
  <div class="method-source-code"
257
263
  id="status-source">
258
264
  <pre>
259
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 107</span>
260
- 107: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">status</span> ; <span class="ruby-ivar">@status</span> ; <span class="ruby-keyword kw">end</span></pre>
265
+ <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 104</span>
266
+ 104: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">status</span> ; <span class="ruby-ivar">@status</span> ; <span class="ruby-keyword kw">end</span></pre>
261
267
  </div>
262
268
 
263
269
  </div>
@@ -288,10 +294,10 @@
288
294
  <div class="method-source-code"
289
295
  id="stderr-source">
290
296
  <pre>
291
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 112</span>
292
- 112: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stderr</span>
293
- 113: <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-ivar">@stderr_file</span>)
294
- 114: <span class="ruby-keyword kw">end</span></pre>
297
+ <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 109</span>
298
+ 109: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stderr</span>
299
+ 110: <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-ivar">@stderr_file</span>)
300
+ 111: <span class="ruby-keyword kw">end</span></pre>
295
301
  </div>
296
302
 
297
303
  </div>
@@ -322,8 +328,8 @@
322
328
  <div class="method-source-code"
323
329
  id="stderr-file-source">
324
330
  <pre>
325
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 106</span>
326
- 106: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stderr_file</span> ; <span class="ruby-ivar">@stderr_file</span> ; <span class="ruby-keyword kw">end</span></pre>
331
+ <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 103</span>
332
+ 103: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stderr_file</span> ; <span class="ruby-ivar">@stderr_file</span> ; <span class="ruby-keyword kw">end</span></pre>
327
333
  </div>
328
334
 
329
335
  </div>
@@ -354,10 +360,10 @@
354
360
  <div class="method-source-code"
355
361
  id="stdout-source">
356
362
  <pre>
357
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 109</span>
358
- 109: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdout</span>
359
- 110: <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-ivar">@stdout_file</span>)
360
- 111: <span class="ruby-keyword kw">end</span></pre>
363
+ <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 106</span>
364
+ 106: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdout</span>
365
+ 107: <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-ivar">@stdout_file</span>)
366
+ 108: <span class="ruby-keyword kw">end</span></pre>
361
367
  </div>
362
368
 
363
369
  </div>
@@ -388,8 +394,8 @@
388
394
  <div class="method-source-code"
389
395
  id="stdout-file-source">
390
396
  <pre>
391
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 105</span>
392
- 105: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdout_file</span> ; <span class="ruby-ivar">@stdout_file</span> ; <span class="ruby-keyword kw">end</span></pre>
397
+ <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 102</span>
398
+ 102: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdout_file</span> ; <span class="ruby-ivar">@stdout_file</span> ; <span class="ruby-keyword kw">end</span></pre>
393
399
  </div>
394
400
 
395
401
  </div>
@@ -420,10 +426,10 @@
420
426
  <div class="method-source-code"
421
427
  id="to-h-source">
422
428
  <pre>
423
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 115</span>
424
- 115: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_h</span>
425
- 116: {<span class="ruby-value">:cmd_str</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@cmd_str</span>,<span class="ruby-value">:stdout</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">stdout</span>, <span class="ruby-value">:stderr</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">stderr</span>, <span class="ruby-value">:status</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">status</span>}
426
- 117: <span class="ruby-keyword kw">end</span></pre>
429
+ <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 112</span>
430
+ 112: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_h</span>
431
+ 113: {<span class="ruby-value">:cmd_str</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@cmd_str</span>,<span class="ruby-value">:stdout</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">stdout</span>, <span class="ruby-value">:stderr</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">stderr</span>, <span class="ruby-value">:status</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">status</span>}
432
+ 114: <span class="ruby-keyword kw">end</span></pre>
427
433
  </div>
428
434
 
429
435
  </div>
@@ -454,10 +460,10 @@
454
460
  <div class="method-source-code"
455
461
  id="to-s-source">
456
462
  <pre>
457
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 118</span>
458
- 118: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
459
- 119: <span class="ruby-identifier">to_h</span>.<span class="ruby-identifier">to_s</span>
460
- 120: <span class="ruby-keyword kw">end</span></pre>
463
+ <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 115</span>
464
+ 115: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
465
+ 116: <span class="ruby-identifier">to_h</span>.<span class="ruby-identifier">to_s</span>
466
+ 117: <span class="ruby-keyword kw">end</span></pre>
461
467
  </div>
462
468
 
463
469
  </div>
@@ -1,9 +1,9 @@
1
- <?xml version="1.0" encoding="harset=UTF-8 "?>
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
- <meta content="text/html; charset=harset=UTF-8 " http-equiv="Content-Type" />
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
7
 
8
8
  <title>Class: RBatch::CommonConfig::Exception</title>
9
9
 
@@ -105,9 +105,15 @@
105
105
 
106
106
  <li><a href="../../RBatch/Config/Exception.html">RBatch::Config::Exception</a></li>
107
107
 
108
+ <li><a href="../../RBatch/DoubleRunCheckException.html">RBatch::DoubleRunCheckException</a></li>
109
+
110
+ <li><a href="../../RBatch/DoubleRunChecker.html">RBatch::DoubleRunChecker</a></li>
111
+
108
112
  <li><a href="../../RBatch/Log.html">RBatch::Log</a></li>
109
113
 
110
- <li><a href="../../RBatchException.html">RBatchException</a></li>
114
+ <li><a href="../../RBatch/RunConf.html">RBatch::RunConf</a></li>
115
+
116
+ <li><a href="../../RBatch/RunConf/Exception.html">RBatch::RunConf::Exception</a></li>
111
117
 
112
118
  </ul>
113
119
  <div id="no-class-search-results" style="display: none;">No matching classes.</div>