rbatch 1.7.0 → 1.8.0

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.
data/lib/rbatch/cmd.rb CHANGED
@@ -30,7 +30,8 @@ module RBatch
30
30
  #
31
31
  class Cmd
32
32
  @@def_opt = {
33
- :raise => false
33
+ :raise => false,
34
+ :timeout => 0
34
35
  }
35
36
  @cmd_str
36
37
  @opt
@@ -41,6 +42,7 @@ module RBatch
41
42
  # +cmd_str+ = Command string. Such ad "ls -l"
42
43
  # +opt+ = Option hash object. Hash keys is follows.
43
44
  # - +:raise+ (Boolean) = If command exit status is not 0, raise exception. Default is false.
45
+ # - +:timeout+ (Integer) = If command timeout , raise exception. Default is 0 sec ( 0 means disable) .
44
46
  def initialize(cmd_str,opt = nil)
45
47
  raise(CmdException,"Command string is nil") if cmd_str.nil?
46
48
  @cmd_str = cmd_str
@@ -68,7 +70,17 @@ module RBatch
68
70
  stdout_file = Tempfile::new("rbatch_tmpout",RBatch::tmp_dir)
69
71
  stderr_file = Tempfile::new("rbatch_tmperr",RBatch::tmp_dir)
70
72
  pid = spawn(@cmd_str,:out => [stdout_file,"w"],:err => [stderr_file,"w"])
71
- status = Process.waitpid2(pid)[1] >> 8
73
+ if @opt[:timeout] != 0
74
+ timeout(@opt[:timeout]) do
75
+ begin
76
+ status = Process.waitpid2(pid)[1] >> 8
77
+ rescue Timeout::Error => e
78
+ raise(CmdException,"Command timeout (over " + @opt[:timeout] + " sec)" )
79
+ end
80
+ end
81
+ else
82
+ status = Process.waitpid2(pid)[1] >> 8
83
+ end
72
84
  result = RBatch::CmdResult.new(stdout_file,stderr_file,status,@cmd_str)
73
85
  if @opt[:raise] && status != 0
74
86
  raise(CmdException,"Command exit status is not 0. result: " + result.to_s)
data/lib/rbatch/log.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'logger'
2
2
  require 'fileutils'
3
3
  require 'pathname'
4
+ require 'net/smtp'
4
5
 
5
6
  module RBatch
6
7
  #=== About RBatch::Log
@@ -26,15 +27,14 @@ module RBatch
26
27
  #
27
28
  #logfile : ./log/20121020_005953_sample1.log
28
29
  #
29
- # # Logfile created on 2012-10-20 00:59:53 +0900 by logger.rb/25413
30
- # I, [2012-10-20T00:59:53.895528 #3208] INFO -- : info string
31
- # E, [2012-10-20T00:59:53.895582 #3208] ERROR -- : error string
32
- # F, [2012-10-20T00:59:53.895629 #3208] FATAL -- : Caught exception; existing 1
33
- # F, [2012-10-20T00:59:53.895667 #3208] FATAL -- : exception (RuntimeError)
34
- # test.rb:6:in `block in <main>'
35
- # /usr/local/lib/ruby192/lib/ruby/gems/1.9.1/gems/rbatch-1.0.0/lib/rbatch/auto_logger.rb:37:in `initialize'
36
- # test.rb:3:in `new'
37
- # test.rb:3:in `<main>'
30
+ # [2012-10-20 00:59:53 +900] [INFO ] info string
31
+ # [2012-10-20 00:59:53 +900] [ERROR] error string
32
+ # [2012-10-20 00:59:53 +900] [FATAL] Caught exception; existing 1
33
+ # [2012-10-20 00:59:53 +900] [FATAL] exception (RuntimeError)
34
+ # [backtrace] test.rb:6:in `block in <main>'
35
+ # [backtrace] /usr/local/lib/ruby192/lib/ruby/gems/1.9.1/gems/rbatch-1.0.0/lib/rbatch/auto_logger.rb:37:in `initialize'
36
+ # [backtrace] test.rb:3:in `new'
37
+ # [backtrace] test.rb:3:in `<main>'
38
38
  #
39
39
  class Log
40
40
  @@verbose = false
@@ -46,7 +46,12 @@ module RBatch
46
46
  :stdout => false,
47
47
  :quiet => false,
48
48
  :delete_old_log => false,
49
- :delete_old_log_date => 7
49
+ :delete_old_log_date => 7,
50
+ :send_mail => false,
51
+ :mail_to => nil,
52
+ :mail_from => "rbatch.localhost",
53
+ :mail_server_host => "localhost",
54
+ :mail_server_port => 25
50
55
  }
51
56
  @@log_level_map = {
52
57
  "debug" => Logger::DEBUG,
@@ -162,11 +167,13 @@ module RBatch
162
167
  def fatal(a)
163
168
  @stdout_log.fatal(a) if @opt[:stdout]
164
169
  @log.fatal(a)
170
+ send_mail(a) if @opt[:send_mail]
165
171
  end
166
172
 
167
173
  def error(a)
168
174
  @stdout_log.error(a) if @opt[:stdout]
169
175
  @log.error(a)
176
+ send_mail(a) if @opt[:send_mail]
170
177
  end
171
178
 
172
179
  def warn(a)
@@ -210,6 +217,26 @@ module RBatch
210
217
  end
211
218
  end
212
219
  end
220
+
221
+ private
222
+
223
+ # send mail
224
+ def send_mail(msg)
225
+ body = <<EOT
226
+ From: <#{@opt[:mail_from]}>
227
+ To: <#{@opt[:mail_to]}>
228
+ Subject: [RBatch] #{RBatch.program_name} has error
229
+ Date: #{Time::now.strftime("%a, %d %b %Y %X %z")}
230
+ Mime-Version: 1.0
231
+ Content-Type: text/plain; charset=ISO-2022-JP
232
+ Content-Transfer-Encoding: 7bit
233
+
234
+ #{msg}
235
+ EOT
236
+ Net::SMTP.start(@opt[:mail_server_host],@opt[:mail_server_port] ) {|smtp|
237
+ smtp.send_mail(body,@opt[:mail_from],@opt[:mail_to])
238
+ }
239
+ end
213
240
  end # end class
214
241
  end # end module
215
242
 
data/lib/rbatch.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
2
-
2
+ require 'digest'
3
3
  module RBatch
4
4
  @@program_name = $PROGRAM_NAME
5
5
  module_function
@@ -31,21 +31,31 @@ module RBatch
31
31
  return nil
32
32
  end
33
33
  end
34
+ def double_run_check
35
+ # double run check
36
+ if ( RBatch::common_config != nil && RBatch::common_config["forbid_double_run"] )
37
+ lock_file="rbatch_lock_" + Digest::MD5.hexdigest(@@program_name)
38
+ if Dir.exists? RBatch::tmp_dir
39
+ Dir::foreach(RBatch::tmp_dir) do |f|
40
+ if (Regexp.new(lock_file) =~ f)
41
+ raise RBatchException, "Script double run is forbid about \"#{RBatch::program_name}\""
42
+ end
43
+ end
44
+ end
45
+ # make lockfile
46
+ Tempfile::new(lock_file,RBatch::tmp_dir)
47
+ end
48
+ end
49
+
50
+ def double_run_lock_file ; ; end
34
51
  end
35
52
 
53
+ # RBatch Exception
54
+ class RBatchException < Exception ; end
55
+
56
+ # main
36
57
  require 'rbatch/log'
37
58
  require 'rbatch/config'
38
59
  require 'rbatch/cmd'
39
60
 
40
- # double run check
41
- if ( RBatch::common_config != nil && RBatch::common_config["forbid_double_run"] )
42
- if Dir.exists? RBatch::tmp_dir
43
- Dir::foreach(RBatch::tmp_dir) do |f|
44
- if (/rbatch_lock/ =~ f)
45
- raise "Can not start RBatch. RBatch lock file exists (#{RBatch::tmp_dir}#{f})."
46
- end
47
- end
48
- end
49
- # make lockfile
50
- Tempfile::new("rbatch_lock",RBatch::tmp_dir)
51
- end
61
+ RBatch::double_run_check
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'rbatch'
3
+
4
+ RBatch::Log.new() do |log|
5
+ sdfa
6
+ end
@@ -0,0 +1,3 @@
1
+ require 'rbatch'
2
+
3
+ sleep 100
@@ -0,0 +1,23 @@
1
+ [2013-01-31 00:50:01 +0900] [INFO ] Start Logging. (PID=24915)
2
+ [2013-01-31 00:50:01 +0900] [INFO ] Start -----------------
3
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:15:40','test.user1','192.168.1.111','server1','GET /test/sample.html HTTP/1.1',4,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','http://www.hoge.develop.jp:8080/amserver/UI/Login?goto=http://www.hoge.develop.jp/test/sample.html')
4
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:15:50','test.user1','192.168.1.111','server1','GET /test/sample.html HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','http://www.hoge.develop.jp:8080/amserver/UI/Login?goto=http://www.hoge.develop.jp/test/sample.html')
5
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:15:59','test.user1','192.168.1.111','server1','GET /test/sample.html HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','http://www.hoge.develop.jp:8080/amserver/UI/Login?goto=http://www.hoge.develop.jp/test/sample.html')
6
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:15:59','test.user1','192.168.1.111','server1','GET /test/sample.html HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','http://www.hoge.develop.jp:8080/amserver/UI/Login?goto=http://www.hoge.develop.jp/test/sample.html')
7
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:16:00','test.user1','192.168.1.111','server1','GET /test/sample.html HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','http://www.hoge.develop.jp:8080/amserver/UI/Login?goto=http://www.hoge.develop.jp/test/sample.html')
8
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:16:00','test.user1','192.168.1.111','server1','GET /test/sample.html HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','http://www.hoge.develop.jp:8080/amserver/UI/Login?goto=http://www.hoge.develop.jp/test/sample.html')
9
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:16:00','test.user1','192.168.1.111','server1','GET /test/sample.html HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','http://www.hoge.develop.jp:8080/amserver/UI/Login?goto=http://www.hoge.develop.jp/test/sample.html')
10
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:16:04','test.user1','-','server1','GET / HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','-')
11
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:22:22','test.user1','-','server1','GET / HTTP/1.1',1,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','-')
12
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:23:11','test.user1','-','server1','GET /test/sample.html HTTP/1.1',0,304,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','-')
13
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:23:33','test.user1','192.168.1.116','server1','GET /test/sample.html HTTP/1.1',0,304,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','-')
14
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:24:48','amadmin','-','server1','GET /test/sample.html HTTP/1.1',0,304,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','http://www.hoge.develop.jp:8080/amserver/UI/Login?goto=http%3A%2F%2Fwww.hoge.develop.jp%2Ftest%2Fsample.html&gx_charset=UTF-8')
15
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 06:25:41','amadmin','-','server1','GET / HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','-')
16
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 22:20:19','-','-','server1','GET / HTTP/1.1',0,403,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','-')
17
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 22:20:19','-','-','server1','GET /favicon.ico HTTP/1.1',0,403,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','-')
18
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 22:23:25','test.user1@example.com','-','server1','GET / HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','-')
19
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 22:24:11','test.user1@example.com','-','server1','GET / HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','-')
20
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 22:24:51','test.user1@example.com','-','server1','GET /test/cmx_test01.html HTTP/1.1',0,404,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','-')
21
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 22:24:52','test.user1@example.com','-','server1','GET /barerrors/js/chgCss.js HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','http://www.hoge.develop.jp/test/cmx_test01.html')
22
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 22:24:52','test.user1@example.com','-','server1','GET /barerrors/images/logo.gif HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','http://www.hoge.develop.jp/test/cmx_test01.html')
23
+ [2013-01-31 00:50:02 +0900] [INFO ] exec sql: INSERT INTO access_log (companyId,date,login_id,access_ip,host_name,access_url,forward_time,httpstatus,user_agent,referer) VALUES ('sample.co','2012/07/10 22:24:52','test.user1@example.com','-','server1','GET /barerrors/images/nri_logo.gif HTTP/1.1',0,200,'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','http://www.hoge.develop.jp/test/cmx_test01.html')
@@ -0,0 +1,128 @@
1
+ [2013-02-09 23:45:26 +0900] [INFO ] Start Logging. (PID=4534)
2
+ [2013-02-09 23:45:26 +0900] [ERROR] hoge
3
+ [2013-02-09 23:45:26 +0900] [FATAL] uninitialized constant RBatch::Log::Mail
4
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:225:in `send_mail'
5
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:177:in `error'
6
+ [backtrace] sample/bin/test.rb:4:in `block in <main>'
7
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
8
+ [backtrace] sample/bin/test.rb:3:in `new'
9
+ [backtrace] sample/bin/test.rb:3:in `<main>'
10
+ [2013-02-09 23:45:29 +0900] [INFO ] Start Logging. (PID=4559)
11
+ [2013-02-09 23:45:29 +0900] [ERROR] hoge
12
+ [2013-02-09 23:45:29 +0900] [FATAL] uninitialized constant RBatch::Log::Mail
13
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:225:in `send_mail'
14
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:177:in `error'
15
+ [backtrace] sample/bin/test.rb:4:in `block in <main>'
16
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
17
+ [backtrace] sample/bin/test.rb:3:in `new'
18
+ [backtrace] sample/bin/test.rb:3:in `<main>'
19
+ [2013-02-09 23:49:58 +0900] [INFO ] Start Logging. (PID=6930)
20
+ [2013-02-09 23:49:58 +0900] [ERROR] hoge
21
+ [2013-02-09 23:49:58 +0900] [FATAL] Connection refused - connect(2)
22
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `initialize'
23
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `open'
24
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `tcp_socket'
25
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `block in do_start'
26
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
27
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
28
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `do_start'
29
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
30
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:463:in `start'
31
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:236:in `send_mail'
32
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:177:in `error'
33
+ [backtrace] sample/bin/test.rb:4:in `block in <main>'
34
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
35
+ [backtrace] sample/bin/test.rb:3:in `new'
36
+ [backtrace] sample/bin/test.rb:3:in `<main>'
37
+ [2013-02-09 23:50:50 +0900] [INFO ] Start Logging. (PID=7387)
38
+ [2013-02-09 23:50:50 +0900] [ERROR] hoge
39
+ [2013-02-09 23:50:50 +0900] [FATAL] Connection refused - connect(2)
40
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `initialize'
41
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `open'
42
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `tcp_socket'
43
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `block in do_start'
44
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
45
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
46
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `do_start'
47
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
48
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:463:in `start'
49
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:236:in `send_mail'
50
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:177:in `error'
51
+ [backtrace] sample/bin/test.rb:4:in `block in <main>'
52
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
53
+ [backtrace] sample/bin/test.rb:3:in `new'
54
+ [backtrace] sample/bin/test.rb:3:in `<main>'
55
+ [2013-02-09 23:51:56 +0900] [INFO ] Start Logging. (PID=7985)
56
+ [2013-02-09 23:51:56 +0900] [ERROR] hoge
57
+ [2013-02-09 23:51:56 +0900] [FATAL] Connection refused - connect(2)
58
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `initialize'
59
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `open'
60
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `tcp_socket'
61
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `block in do_start'
62
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
63
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
64
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `do_start'
65
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
66
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:463:in `start'
67
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:236:in `send_mail'
68
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:177:in `error'
69
+ [backtrace] sample/bin/test.rb:4:in `block in <main>'
70
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
71
+ [backtrace] sample/bin/test.rb:3:in `new'
72
+ [backtrace] sample/bin/test.rb:3:in `<main>'
73
+ [2013-02-09 23:52:30 +0900] [INFO ] Start Logging. (PID=8283)
74
+ [2013-02-09 23:52:30 +0900] [ERROR] hoge
75
+ [2013-02-09 23:52:30 +0900] [FATAL] Connection refused - connect(2)
76
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `initialize'
77
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `open'
78
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `tcp_socket'
79
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `block in do_start'
80
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
81
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
82
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `do_start'
83
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
84
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:463:in `start'
85
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:237:in `send_mail'
86
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:177:in `error'
87
+ [backtrace] sample/bin/test.rb:4:in `block in <main>'
88
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
89
+ [backtrace] sample/bin/test.rb:3:in `new'
90
+ [backtrace] sample/bin/test.rb:3:in `<main>'
91
+ [2013-02-09 23:53:20 +0900] [INFO ] Start Logging. (PID=8715)
92
+ [2013-02-09 23:53:20 +0900] [ERROR] hoge
93
+ [2013-02-09 23:53:20 +0900] [FATAL] Connection refused - connect(2)
94
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `initialize'
95
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `open'
96
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `tcp_socket'
97
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `block in do_start'
98
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
99
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
100
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `do_start'
101
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
102
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:463:in `start'
103
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:238:in `send_mail'
104
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:177:in `error'
105
+ [backtrace] sample/bin/test.rb:4:in `block in <main>'
106
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
107
+ [backtrace] sample/bin/test.rb:3:in `new'
108
+ [backtrace] sample/bin/test.rb:3:in `<main>'
109
+ [2013-02-09 23:53:57 +0900] [INFO ] Start Logging. (PID=9030)
110
+ [2013-02-09 23:53:57 +0900] [ERROR] hoge
111
+ [2013-02-09 23:53:57 +0900] [FATAL] Connection refused - connect(2)
112
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `initialize'
113
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `open'
114
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `tcp_socket'
115
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `block in do_start'
116
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
117
+ [backtrace] /usr/local/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
118
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `do_start'
119
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
120
+ [backtrace] /usr/local/lib/ruby/1.9.1/net/smtp.rb:463:in `start'
121
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:238:in `send_mail'
122
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:177:in `error'
123
+ [backtrace] sample/bin/test.rb:4:in `block in <main>'
124
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
125
+ [backtrace] sample/bin/test.rb:3:in `new'
126
+ [backtrace] sample/bin/test.rb:3:in `<main>'
127
+ [2013-02-09 23:54:47 +0900] [INFO ] Start Logging. (PID=9475)
128
+ [2013-02-09 23:54:47 +0900] [ERROR] hoge
@@ -0,0 +1,68 @@
1
+ [2013-02-10 00:20:47 +0900] [INFO ] Start Logging. (PID=22781)
2
+ [2013-02-10 00:20:47 +0900] [ERROR] hoge
3
+ [2013-02-10 00:22:07 +0900] [INFO ] Start Logging. (PID=23451)
4
+ [2013-02-10 00:22:07 +0900] [ERROR] hoge
5
+ [2013-02-10 00:26:18 +0900] [INFO ] Start Logging. (PID=25582)
6
+ [2013-02-10 00:26:18 +0900] [ERROR] hoge
7
+ [2013-02-10 00:27:28 +0900] [INFO ] Start Logging. (PID=26168)
8
+ [2013-02-10 00:27:28 +0900] [ERROR] hoge
9
+ [2013-02-10 00:28:07 +0900] [INFO ] Start Logging. (PID=26488)
10
+ [2013-02-10 00:28:07 +0900] [ERROR] hoge
11
+ [2013-02-10 00:30:05 +0900] [INFO ] Start Logging. (PID=27499)
12
+ [2013-02-10 00:30:05 +0900] [ERROR] 日本語
13
+ [2013-02-10 00:31:26 +0900] [INFO ] Start Logging. (PID=28196)
14
+ [2013-02-10 00:31:26 +0900] [FATAL] undefined local variable or method `sdfa' for main:Object
15
+ [backtrace] sample/bin/test.rb:5:in `block in <main>'
16
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
17
+ [backtrace] sample/bin/test.rb:4:in `new'
18
+ [backtrace] sample/bin/test.rb:4:in `<main>'
19
+ [2013-02-10 00:31:27 +0900] [FATAL] Caught exception. Exit 1
20
+ [2013-02-10 00:32:16 +0900] [INFO ] Start Logging. (PID=28628)
21
+ [2013-02-10 00:32:16 +0900] [FATAL] undefined local variable or method `sdfa' for main:Object
22
+ [backtrace] sample/bin/test.rb:5:in `block in <main>'
23
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
24
+ [backtrace] sample/bin/test.rb:4:in `new'
25
+ [backtrace] sample/bin/test.rb:4:in `<main>'
26
+ [2013-02-10 00:32:16 +0900] [FATAL] Caught exception. Exit 1
27
+ [2013-02-10 00:34:19 +0900] [INFO ] Start Logging. (PID=29673)
28
+ [2013-02-10 00:34:19 +0900] [FATAL] undefined local variable or method `sdfa' for main:Object
29
+ [backtrace] sample/bin/test.rb:5:in `block in <main>'
30
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
31
+ [backtrace] sample/bin/test.rb:4:in `new'
32
+ [backtrace] sample/bin/test.rb:4:in `<main>'
33
+ [2013-02-10 00:34:19 +0900] [FATAL] Caught exception. Exit 1
34
+ [2013-02-10 00:40:24 +0900] [INFO ] Start Logging. (PID=372)
35
+ [2013-02-10 00:40:24 +0900] [FATAL] undefined local variable or method `sdfa' for main:Object
36
+ [backtrace] sample/bin/test.rb:5:in `block in <main>'
37
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
38
+ [backtrace] sample/bin/test.rb:4:in `new'
39
+ [backtrace] sample/bin/test.rb:4:in `<main>'
40
+ [2013-02-10 00:40:24 +0900] [FATAL] Caught exception. Exit 1
41
+ [2013-02-10 00:40:53 +0900] [INFO ] Start Logging. (PID=638)
42
+ [2013-02-10 00:40:53 +0900] [FATAL] undefined local variable or method `sdfa' for main:Object
43
+ [backtrace] sample/bin/test.rb:5:in `block in <main>'
44
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
45
+ [backtrace] sample/bin/test.rb:4:in `new'
46
+ [backtrace] sample/bin/test.rb:4:in `<main>'
47
+ [2013-02-10 00:40:53 +0900] [FATAL] Caught exception. Exit 1
48
+ [2013-02-10 00:41:08 +0900] [INFO ] Start Logging. (PID=759)
49
+ [2013-02-10 00:41:08 +0900] [FATAL] undefined local variable or method `sdfa' for main:Object
50
+ [backtrace] sample/bin/test.rb:5:in `block in <main>'
51
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
52
+ [backtrace] sample/bin/test.rb:4:in `new'
53
+ [backtrace] sample/bin/test.rb:4:in `<main>'
54
+ [2013-02-10 00:41:08 +0900] [FATAL] Caught exception. Exit 1
55
+ [2013-02-10 00:48:46 +0900] [INFO ] Start Logging. (PID=4706)
56
+ [2013-02-10 00:48:46 +0900] [FATAL] undefined local variable or method `sdfa' for main:Object
57
+ [backtrace] sample/bin/test.rb:5:in `block in <main>'
58
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
59
+ [backtrace] sample/bin/test.rb:4:in `new'
60
+ [backtrace] sample/bin/test.rb:4:in `<main>'
61
+ [2013-02-10 00:48:46 +0900] [FATAL] Caught exception. Exit 1
62
+ [2013-02-10 00:49:11 +0900] [INFO ] Start Logging. (PID=4922)
63
+ [2013-02-10 00:49:11 +0900] [FATAL] undefined local variable or method `sdfa' for main:Object
64
+ [backtrace] sample/bin/test.rb:5:in `block in <main>'
65
+ [backtrace] /root/rbatch/lib/rbatch/log.rb:157:in `initialize'
66
+ [backtrace] sample/bin/test.rb:4:in `new'
67
+ [backtrace] sample/bin/test.rb:4:in `<main>'
68
+ [2013-02-10 00:49:11 +0900] [FATAL] Caught exception. Exit 1
@@ -117,4 +117,16 @@ class RuncherTest < Test::Unit::TestCase
117
117
  RBatch::cmd(cmd_str,opt)
118
118
  }
119
119
  end
120
+ def test_opt_timeout
121
+ cmd_str = "ruby -e 'sleep 2'"
122
+ opt = {:timeout => 1}
123
+ assert_raise(RBatch::CmdException){
124
+ RBatch::cmd(cmd_str,opt)
125
+ }
126
+ end
127
+ def test_opt_timeout
128
+ cmd_str = "ruby -e 'sleep 1'"
129
+ opt = {:timeout => 2}
130
+ RBatch::cmd(cmd_str,opt)
131
+ end
120
132
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rbatch
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.7.0
5
+ version: 1.8.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - fetaro
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-01-30 00:00:00 Z
13
+ date: 2013-02-09 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: ""
@@ -44,12 +44,15 @@ files:
44
44
  - sample/data/amAuthentication.error.2012-07-10
45
45
  - sample/data/amAgent_localhost_80.log.1
46
46
  - sample/data/amAuthentication.access.1
47
+ - sample/log/20130131_apache_log_insert.log
47
48
  - sample/log/20130120_openam_log_insert.log
49
+ - sample/log/20130210_test.log
48
50
  - sample/log/20130122_apache_log_insert.log
49
51
  - sample/log/20130122_openam_log_insert.log
50
52
  - sample/log/20130121_webagent_log_insert.log
51
53
  - sample/log/20130129_log_backup.log
52
54
  - sample/log/20130121_file_batch_copy.log
55
+ - sample/log/20130209_test.log
53
56
  - sample/log/20130120_apache_log_insert.log
54
57
  - sample/log/empty
55
58
  - sample/log/20130122_webagent_log_insert.log
@@ -63,9 +66,11 @@ files:
63
66
  - sample/conf/file_batch_copy.yaml
64
67
  - sample/conf/rbatch.yaml
65
68
  - sample/conf/openam_log_insert.yaml
69
+ - sample/bin/test2.rb
66
70
  - sample/bin/apache_log_insert.rb
67
71
  - sample/bin/openldap_backup.rb
68
72
  - sample/bin/webagent_log_insert.rb
73
+ - sample/bin/test.rb
69
74
  - sample/bin/mysql_data_backup.rb
70
75
  - sample/bin/openam_log_insert.rb
71
76
  - sample/bin/file_batch_copy.rb
@@ -134,6 +139,7 @@ files:
134
139
  - doc/rdoc/js/thickbox-compressed.js
135
140
  - doc/rdoc/LICENSE.html
136
141
  - doc/rdoc/CHANGELOG.html
142
+ - doc/rdoc/RBatchException.html
137
143
  homepage: https://github.com/fetaro/rbatch
138
144
  licenses: []
139
145