rbatch 2.1.4 → 2.1.5
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/.gitignore +1 -0
- data/README.ja.md +94 -95
- data/README.md +75 -70
- data/bin/rbatch-init +64 -51
- data/lib/rbatch/journal.rb +3 -7
- data/lib/rbatch/log.rb +4 -1
- data/lib/rbatch/run_conf.rb +6 -6
- data/lib/rbatch/variables.rb +0 -6
- data/lib/rbatch/version.rb +1 -1
- data/rbatch.gemspec +2 -2
- data/sample/.rbatchrc +43 -45
- data/spec/rbatch/journal_spec.rb +0 -12
- data/spec/rbatch/run_conf_spec.rb +5 -6
- data/spec/rbatch/variables_spec.rb +0 -4
- metadata +4 -16
- data/sample/bin/ftp_get.rb +0 -20
- data/sample/bin/store_to_idm.rb +0 -10
- data/sample/data/access_log.1 +0 -50
- data/sample/data/access_log.2012-07-10 +0 -50
- data/sample/data/amAgent_localhost_80.log.1 +0 -39
- data/sample/data/amAgent_localhost_80.log.2012-07-10 +0 -40
- data/sample/data/amAuthentication.access.1 +0 -30
- data/sample/data/amAuthentication.access.2012-07-10 +0 -30
- data/sample/data/amAuthentication.error.1 +0 -10
- data/sample/data/amAuthentication.error.2012-07-10 +0 -6
- data/sample/lib/openidm_common_func.rb +0 -46
- data/sample/log/empty +0 -0
- /data/sample/{conf/store_to_idm.yaml → lib/.gitkeep} +0 -0
data/.gitignore
CHANGED
data/README.ja.md
CHANGED
@@ -6,7 +6,7 @@ RBatch:Ruby-base バッチ スクリプト フレームワーク
|
|
6
6
|
RBatchについて (version 2)
|
7
7
|
--------------
|
8
8
|
|
9
|
-
|
9
|
+
RBatchはRubyで書かれたシンプルなバッチスクリプトのフレームワークです。
|
10
10
|
バッチスクリプト(バックアップやプロセスリロード等)を書く際に便利な機能をフレームワークとして提供しています。
|
11
11
|
|
12
12
|
主な機能は以下のとおり。
|
@@ -59,6 +59,7 @@ RBatchでは、実行スクリプト、設定ファイルおよびログファ
|
|
59
59
|
|-conf ←設定ファイル配置場所
|
60
60
|
| |- A.yaml
|
61
61
|
| |- B.yaml
|
62
|
+
| |- common.yaml ←共通設定ファイル
|
62
63
|
|
|
63
64
|
|-log ←ログ出力場所
|
64
65
|
| |- YYYYMMDD_HHMMSS_A.log
|
@@ -70,35 +71,35 @@ RBatchでは、実行スクリプト、設定ファイルおよびログファ
|
|
70
71
|
|
71
72
|
### 自動ログ出力
|
72
73
|
|
73
|
-
|
74
|
+
ログブロックを使うことで、自動的にログファイルに出力することができます。
|
74
75
|
ログファイルはデフォルトで`${RB_HOME}/log/YYYYMMDD_HHMMSS_(スクリプトのbasename).log`に出力されます。
|
75
|
-
|
76
|
+
ログブロック内で発生した例外をキャッチし、ログにスタックトレースを出力することができます。
|
76
77
|
|
77
78
|
サンプル
|
78
79
|
|
79
|
-
|
80
|
-
```
|
81
|
-
require 'rbatch'
|
80
|
+
スクリプト`${RB_HOME}/bin/sample1.rb` を作ります
|
82
81
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
82
|
+
require 'rbatch'
|
83
|
+
|
84
|
+
RBatch::Log.new(){ |log| # ログブロック
|
85
|
+
log.info "info string"
|
86
|
+
log.error "error string"
|
87
|
+
raise "exception"
|
88
|
+
}
|
89
|
+
|
90
|
+
|
91
|
+
実行するとログファイル`${RB_HOME}/log/20121020_005953_sample1.log`が以下のように出力されます
|
92
|
+
|
93
|
+
# Logfile created on 2012-10-20 00:59:53 +0900 by logger.rb/25413
|
94
|
+
[2012-10-20 00:59:53 +900] [INFO ] info string
|
95
|
+
[2012-10-20 00:59:53 +900] [ERROR] error string
|
96
|
+
[2012-10-20 00:59:53 +900] [FATAL] Caught exception; existing 1
|
97
|
+
[2012-10-20 00:59:53 +900] [FATAL] exception (RuntimeError)
|
98
|
+
[backtrace] test.rb:6:in `block in <main>'
|
99
|
+
[backtrace] /usr/local/lib/ruby192/lib/ruby/gems/1.9.1/gems/rbatch-1.0.0/lib/rbatch/auto_logger.rb:37:in `initialize'
|
100
|
+
[backtrace] test.rb:3:in `new'
|
101
|
+
[backtrace] test.rb:3:in `<main>'
|
89
102
|
|
90
|
-
ログファイル : ${RB_HOME}/log/20121020_005953_sample1.log
|
91
|
-
```
|
92
|
-
# Logfile created on 2012-10-20 00:59:53 +0900 by logger.rb/25413
|
93
|
-
[2012-10-20 00:59:53 +900] [INFO ] info string
|
94
|
-
[2012-10-20 00:59:53 +900] [ERROR] error string
|
95
|
-
[2012-10-20 00:59:53 +900] [FATAL] Caught exception; existing 1
|
96
|
-
[2012-10-20 00:59:53 +900] [FATAL] exception (RuntimeError)
|
97
|
-
[backtrace] test.rb:6:in `block in <main>'
|
98
|
-
[backtrace] /usr/local/lib/ruby192/lib/ruby/gems/1.9.1/gems/rbatch-1.0.0/lib/rbatch/auto_logger.rb:37:in `initialize'
|
99
|
-
[backtrace] test.rb:3:in `new'
|
100
|
-
[backtrace] test.rb:3:in `<main>'
|
101
|
-
```
|
102
103
|
|
103
104
|
### 自動ライブラリ読み込み
|
104
105
|
|
@@ -115,50 +116,50 @@ RBatchは簡単にデフォルトの位置の設定ファイルを読み込め
|
|
115
116
|
|
116
117
|
サンプル
|
117
118
|
|
118
|
-
設定ファイル
|
119
|
-
```
|
120
|
-
key: value
|
121
|
-
array:
|
122
|
-
- item1
|
123
|
-
- item2
|
124
|
-
- item3
|
125
|
-
```
|
119
|
+
設定ファイル `${RB_HOME}/conf/sample2.yaml` を作ります
|
126
120
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
121
|
+
key: value
|
122
|
+
array:
|
123
|
+
- item1
|
124
|
+
- item2
|
125
|
+
- item3
|
126
|
+
|
127
|
+
|
128
|
+
スクリプト`${RB_HOME}/bin/sample2.rb`で、以下のように設定値を呼び出すことができます。
|
129
|
+
|
130
|
+
require 'rbatch'
|
131
|
+
|
132
|
+
# 設定ファイルのロードなど無しにいきなり設定値を利用できます
|
133
|
+
p RBatch.config["key"] # => "value"
|
134
|
+
p RBatch.config["array"] # => ["item1", "item2", "item3"]
|
135
|
+
|
136
|
+
# もしキーが存在しない場合は自動的に例外が発生します
|
137
|
+
p RBatch.config["not_exist"] # => RBatch::ConfigExceptionが発生
|
138
|
+
|
139
|
+
|
140
|
+
#### 共通設定ファイル
|
139
141
|
|
140
142
|
すべてのスクリプトから共通で読み込む設定ファイルを作りたい場合は、`${RB_HOME}/conf/common.yaml`というファイルを作ることで可能です。
|
141
143
|
|
142
|
-
### 外部コマンド実行
|
144
|
+
### 外部コマンド実行
|
143
145
|
|
144
146
|
RBatchは外部コマンド(たとえば"ls -l")を実行するラッパー関数を提供します。
|
145
147
|
|
146
148
|
この関数は、実行結果をオブジェクトで返し、そのオブジェクトは標準出力、標準エラー出力、およびexitステータスを含みます。
|
147
149
|
|
148
150
|
サンプル
|
149
|
-
|
150
|
-
require 'rbatch'
|
151
|
-
r = RBatch.cmd("ls")
|
152
|
-
p r.stdout
|
153
|
-
=> "
|
154
|
-
p r.
|
155
|
-
|
156
|
-
p r.status
|
157
|
-
=> 0
|
158
|
-
```
|
151
|
+
|
152
|
+
require 'rbatch'
|
153
|
+
r = RBatch.cmd("ls")
|
154
|
+
p r.stdout # => "fileA\nfileB\n"
|
155
|
+
p r.stderr # => ""
|
156
|
+
p r.status # => 0
|
157
|
+
|
159
158
|
|
160
159
|
外部コマンドにタイムアウトを設定したい場合は`cmd_timeout`をオプションを利用できます。
|
161
160
|
|
161
|
+
`cmd_raise`オプションを利用することにより、コマンドの戻り値が0以外の場合、例外を発生させることができます。これによりエラーハンドリングのロジックを省略できます。
|
162
|
+
|
162
163
|
### 二重起動チェック
|
163
164
|
|
164
165
|
`forbid_double_run`のオプションを利用すれば、RBatchを利用したプログラムの二重起動チェックができます。
|
@@ -192,8 +193,8 @@ Run-Conf(`${RB_HOME}/.rbatchrc`)のサンプルは以下の通り
|
|
192
193
|
# デフォルトは "<home>/conf"
|
193
194
|
# <home> は ${RB_HOME} に置き換わります
|
194
195
|
#
|
195
|
-
#conf_dir: <home>/config
|
196
|
-
#conf_dir: /etc/rbatch/
|
196
|
+
#conf_dir : <home>/config
|
197
|
+
#conf_dir : /etc/rbatch/
|
197
198
|
|
198
199
|
# スクリプト間共通設定ファイル名
|
199
200
|
#
|
@@ -206,41 +207,42 @@ Run-Conf(`${RB_HOME}/.rbatchrc`)のサンプルは以下の通り
|
|
206
207
|
# デフォルトは"<home>/lib"
|
207
208
|
# <home> は${RB_HOME}に置き換わります
|
208
209
|
#
|
209
|
-
#lib_dir: /usr/local/lib/rbatch/
|
210
|
+
#lib_dir : /usr/local/lib/rbatch/
|
210
211
|
|
211
212
|
# 自動ライブラリ読み込み
|
212
213
|
#
|
213
214
|
# デフォルトはtrue
|
214
215
|
# trueの場合、スクリプトが始まる前に"(ライブラリディレクトリ)/*.rb"をrequireします
|
215
216
|
#
|
216
|
-
#auto_lib_load: true
|
217
|
-
#auto_lib_load: false
|
217
|
+
#auto_lib_load : true
|
218
|
+
#auto_lib_load : false
|
218
219
|
|
219
220
|
# スクリプトの二重起動を可能にするかどうか
|
220
221
|
#
|
221
222
|
# デフォルト値はfalse。
|
222
223
|
# trueにすると、同じ名前のスクリプトは二つ同時に起動できなくなります。
|
223
224
|
#
|
224
|
-
#forbid_double_run: true
|
225
|
-
#forbid_double_run: false
|
225
|
+
#forbid_double_run : true
|
226
|
+
#forbid_double_run : false
|
226
227
|
|
227
|
-
#
|
228
|
-
# 外部コマンド実行関連
|
229
|
-
# -------------------
|
230
|
-
|
231
|
-
# 例外発生機能を有効にするかどうか
|
228
|
+
# RBatchの実行ログ(Journal)のLevel
|
232
229
|
#
|
233
|
-
#
|
234
|
-
#
|
230
|
+
# デフォルトは1
|
231
|
+
# 大きい数を指定すると多くの実行ログが出力される。
|
232
|
+
# 0を指定すると何も表示されない。
|
233
|
+
# RBatchメッセージの例
|
234
|
+
# [RBatch] Load Config : "../conf/hoge.yaml"
|
235
235
|
#
|
236
|
-
#
|
237
|
-
#
|
236
|
+
#rbatch_journal_level : 2
|
237
|
+
#rbatch_journal_level : 0
|
238
238
|
|
239
|
-
#
|
239
|
+
# RBatchの実行ログをログに混ぜ込む
|
240
240
|
#
|
241
|
-
#
|
241
|
+
# デフォルトは true。
|
242
|
+
# trueを指定すると、RBatchメッセージをその時開かれているログに混ぜこむ。
|
242
243
|
#
|
243
|
-
#
|
244
|
+
#mix_rbatch_journal_to_logs : true
|
245
|
+
#mix_rbatch_journal_to_logs : false
|
244
246
|
|
245
247
|
# -------------------
|
246
248
|
# ログ関連
|
@@ -251,8 +253,8 @@ Run-Conf(`${RB_HOME}/.rbatchrc`)のサンプルは以下の通り
|
|
251
253
|
# デフォルトは "<home>/log"
|
252
254
|
# <home> は ${RB_HOME} に置き換わります
|
253
255
|
#
|
254
|
-
#log_dir: <home>/rb_log
|
255
|
-
#log_dir: /var/log/rbatch/
|
256
|
+
#log_dir : <home>/rb_log
|
257
|
+
#log_dir : /var/log/rbatch/
|
256
258
|
|
257
259
|
# ログファイル名
|
258
260
|
#
|
@@ -278,10 +280,7 @@ Run-Conf(`${RB_HOME}/.rbatchrc`)のサンプルは以下の通り
|
|
278
280
|
# 設定できる値は"debug","info","wran","error","fatal"。
|
279
281
|
#
|
280
282
|
#log_level : "debug"
|
281
|
-
#log_level : "info"
|
282
283
|
#log_level : "warn"
|
283
|
-
#log_level : "error"
|
284
|
-
#log_level : "fatal"
|
285
284
|
|
286
285
|
# 標準出力とログの両方に文字列を出力するかどうか
|
287
286
|
#
|
@@ -298,14 +297,14 @@ Run-Conf(`${RB_HOME}/.rbatchrc`)のサンプルは以下の通り
|
|
298
297
|
# 同じファイル名フォーマットであり、かつログファイル名のフォーマットに<date>が
|
299
298
|
# 含まれるもの。
|
300
299
|
#
|
301
|
-
#log_delete_old_log: true
|
302
|
-
#log_delete_old_log: false
|
300
|
+
#log_delete_old_log : true
|
301
|
+
#log_delete_old_log : false
|
303
302
|
|
304
303
|
# 古いログの残す日数
|
305
304
|
#
|
306
305
|
# デフォルト値は 7
|
307
306
|
#
|
308
|
-
#log_delete_old_log_date: 14
|
307
|
+
#log_delete_old_log_date : 14
|
309
308
|
|
310
309
|
# メール送信するかどうか
|
311
310
|
#
|
@@ -321,24 +320,24 @@ Run-Conf(`${RB_HOME}/.rbatchrc`)のサンプルは以下の通り
|
|
321
320
|
#log_mail_server_host : "localhost"
|
322
321
|
#log_mail_server_port : 25
|
323
322
|
|
324
|
-
#
|
323
|
+
# -------------------
|
324
|
+
# 外部コマンド実行関連
|
325
|
+
# -------------------
|
326
|
+
|
327
|
+
# 例外発生機能を有効にするかどうか
|
325
328
|
#
|
326
|
-
#
|
327
|
-
#
|
328
|
-
# 0を指定すると何も表示されない。
|
329
|
-
# RBatchメッセージの例
|
330
|
-
# [RBatch] Load Config : "../conf/hoge.yaml"
|
329
|
+
# デフォルト値はfalse。
|
330
|
+
# trueの場合、コマンドの終了ステータスが0でない場合に例外を発生する。
|
331
331
|
#
|
332
|
-
#
|
333
|
-
#
|
332
|
+
#cmd_raise : true
|
333
|
+
#cmd_raise : false
|
334
334
|
|
335
|
-
#
|
335
|
+
# 外部コマンドのタイムアウト
|
336
336
|
#
|
337
|
-
#
|
338
|
-
# trueを指定すると、RBatchメッセージをその時開かれているログに混ぜこむ。
|
337
|
+
# デフォルト値は0[sec]。
|
339
338
|
#
|
340
|
-
#
|
341
|
-
|
339
|
+
#cmd_timeout : 5
|
340
|
+
|
342
341
|
|
343
342
|
```
|
344
343
|
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
[[English]](https://github.com/fetaro/rbatch/blob/master/README.md "english") [[Japanese]](https://github.com/fetaro/rbatch/blob/master/README.ja.md "japanese")
|
2
2
|
|
3
|
-
RBatch:Ruby-
|
3
|
+
RBatch: Framework for Ruby-based Batch Script
|
4
4
|
=============
|
5
5
|
|
6
6
|
About RBatch (for ver 2)
|
7
7
|
--------------
|
8
8
|
|
9
9
|
|
10
|
-
RBatch is Ruby-
|
10
|
+
RBatch is a framework for Ruby-based batch script. RBatch help to make a batch script such as "data backup" or "proccess start ".
|
11
11
|
|
12
12
|
There are following functions.
|
13
13
|
|
@@ -59,6 +59,7 @@ For example
|
|
59
59
|
|- conf <--- Config files
|
60
60
|
| |- A.yaml
|
61
61
|
| |- B.yaml
|
62
|
+
| |- common.yaml <--- Common-Config file
|
62
63
|
|
|
63
64
|
|- log <--- Log files
|
64
65
|
| |- YYYYMMDD_HHMMSS_A.log
|
@@ -76,7 +77,7 @@ If an exception is raised, then RBatch write the stack trace to the logfile.
|
|
76
77
|
|
77
78
|
sample
|
78
79
|
|
79
|
-
script
|
80
|
+
make script `${RB_HOME}/bin/sample1.rb`
|
80
81
|
|
81
82
|
require 'rbatch'
|
82
83
|
RBatch::Log.new(){ |log| # Logging block
|
@@ -85,7 +86,8 @@ script : `${RB_HOME}/bin/sample1.rb`
|
|
85
86
|
raise "exception"
|
86
87
|
}
|
87
88
|
|
88
|
-
|
89
|
+
|
90
|
+
Run script. Log file is `${RB_HOME}/log/20121020_005953_sample1.log`
|
89
91
|
|
90
92
|
# Logfile created on 2012-10-20 00:59:53 +0900 by logger.rb/25413
|
91
93
|
[2012-10-20 00:59:53 +900] [INFO ] info string
|
@@ -111,7 +113,7 @@ If you make configuration file which is located `${RB_HOME}/conf/"(script base).
|
|
111
113
|
|
112
114
|
sample
|
113
115
|
|
114
|
-
config
|
116
|
+
make config file `${RB_HOME}/conf/sample2.yaml`.
|
115
117
|
|
116
118
|
key: value
|
117
119
|
array:
|
@@ -119,24 +121,24 @@ config : `${RB_HOME}/conf/sample2.yaml`
|
|
119
121
|
- item2
|
120
122
|
- item3
|
121
123
|
|
122
|
-
|
123
|
-
script : `${RB_HOME}/bin/sample2.rb`
|
124
|
+
In script `${RB_HOME}/bin/sample2.rb` , you can read config.
|
124
125
|
|
125
126
|
require 'rbatch'
|
126
|
-
p RBatch.config
|
127
|
-
=> {"key" => "value", "array" => ["item1", "item2", "item3"]}
|
128
|
-
p RBatch.config["key"]
|
129
|
-
=> "value"
|
130
127
|
|
131
|
-
#
|
132
|
-
p RBatch.config["
|
133
|
-
=>
|
128
|
+
# You can read config value without loading file.
|
129
|
+
p RBatch.config["key"] # => "value"
|
130
|
+
p RBatch.config["array"] # => ["item1", "item2", "item3"]
|
131
|
+
|
132
|
+
# If key does not exist, raise exception
|
133
|
+
p RBatch.config["not_exist"] # => Raise RBatch::ConfigException
|
134
134
|
|
135
135
|
|
136
|
+
#### Common Config
|
137
|
+
|
136
138
|
If you can use a common config file which is read from all scripts, you make `${RB_HOME}/conf/common.yaml`.
|
137
139
|
You can change name of common config file by using option `common_conf_name`.
|
138
140
|
|
139
|
-
### External Command Wrapper
|
141
|
+
### External Command Wrapper
|
140
142
|
|
141
143
|
RBatch provide a function which wrap external command (such as 'ls').
|
142
144
|
|
@@ -146,24 +148,24 @@ sample
|
|
146
148
|
|
147
149
|
require 'rbatch'
|
148
150
|
r = RBatch.cmd("ls")
|
149
|
-
p r.stdout
|
150
|
-
=> "
|
151
|
-
p r.
|
152
|
-
=> ""
|
153
|
-
p r.status
|
154
|
-
=> 0
|
151
|
+
p r.stdout # => "fileA\nfileB\n"
|
152
|
+
p r.stderr # => ""
|
153
|
+
p r.status # => 0
|
155
154
|
|
156
155
|
If you want to set a timeout of external command, you can use `cmd_timeout` option.
|
157
156
|
|
157
|
+
And by using `cmd_raise` option, if status of command is not 0, raise Exception.
|
158
|
+
You have no use for an error handring.
|
159
|
+
|
158
160
|
### Double Run Check
|
159
161
|
|
160
|
-
Using `forbid_double_run` option, two same name scripts cannot run at the same time.
|
162
|
+
Using `forbid_double_run` option, two same name scripts cannot run at the same time.
|
161
163
|
|
162
164
|
Customize
|
163
165
|
--------------
|
164
166
|
If you want to customize RBatch, you have two methods.
|
165
167
|
|
166
|
-
* (1) Write Run-Conf
|
168
|
+
* (1) Write Run-Conf(`${RB_HOME}/.rbatchrc`).
|
167
169
|
* (2) Pass an option object to constructor in your script.
|
168
170
|
|
169
171
|
When an option is set in both (1) and (2), (2) is prior to (1).
|
@@ -171,6 +173,7 @@ When an option is set in both (1) and (2), (2) is prior to (1).
|
|
171
173
|
#### Customize by writing Run-Conf (.rbatchrc)
|
172
174
|
|
173
175
|
Sample of RBatch Run-Conf `${RB_HOME}/.rbatchrc`.
|
176
|
+
|
174
177
|
```
|
175
178
|
# RBatch Run-Conf (.rbatchrc)
|
176
179
|
#
|
@@ -186,14 +189,14 @@ Sample of RBatch Run-Conf `${RB_HOME}/.rbatchrc`.
|
|
186
189
|
# Default is "<home>/conf"
|
187
190
|
# <home> is replaced to ${RB_HOME}
|
188
191
|
#
|
189
|
-
#conf_dir: <home>/config/
|
190
|
-
#conf_dir: /etc/rbatch/
|
192
|
+
#conf_dir : <home>/config/
|
193
|
+
#conf_dir : /etc/rbatch/
|
191
194
|
|
192
|
-
# Common
|
195
|
+
# Common Config file name
|
193
196
|
#
|
194
197
|
# Default is "common.yaml"
|
195
198
|
#
|
196
|
-
#common_conf_name: share.yaml
|
199
|
+
#common_conf_name : share.yaml
|
197
200
|
|
198
201
|
# Library Directory
|
199
202
|
#
|
@@ -207,34 +210,35 @@ Sample of RBatch Run-Conf `${RB_HOME}/.rbatchrc`.
|
|
207
210
|
# Default is true
|
208
211
|
# If true, require "(library directory)/*.rb" before script run.
|
209
212
|
#
|
210
|
-
#auto_lib_load: true
|
211
|
-
#auto_lib_load: false
|
213
|
+
#auto_lib_load : true
|
214
|
+
#auto_lib_load : false
|
212
215
|
|
213
|
-
# Forbit Script
|
216
|
+
# Forbit Script Running Doubly
|
214
217
|
#
|
215
218
|
# Default is false.
|
216
|
-
# If true, two same name scripts cannot run at the same time.
|
219
|
+
# If true, two same name scripts cannot run at the same time.
|
217
220
|
#
|
218
221
|
#forbid_double_run: true
|
219
222
|
#forbid_double_run: false
|
220
223
|
|
221
|
-
#
|
222
|
-
# Cmd setting
|
223
|
-
# -------------------
|
224
|
-
|
225
|
-
# Raise Exception
|
224
|
+
# Journal Message Level
|
226
225
|
#
|
227
|
-
# Default is
|
228
|
-
# If
|
226
|
+
# Default is 1
|
227
|
+
# If 2, put more journal messages to STDOUT.
|
228
|
+
# If 0, put nothing.
|
229
|
+
# Example of journal essages are follows.
|
230
|
+
# [RBatch] Load Config : "../conf/hoge.yaml"
|
229
231
|
#
|
230
|
-
#
|
231
|
-
#
|
232
|
+
#rbatch_journal_level : 2
|
233
|
+
#rbatch_journal_level : 0
|
232
234
|
|
233
|
-
#
|
235
|
+
# Mix Journal Message to Logs
|
234
236
|
#
|
235
|
-
# Default is
|
237
|
+
# Default is true.
|
238
|
+
# If true, mix RBatch journal messages to log file(s) which is(are) opened at time.
|
236
239
|
#
|
237
|
-
#
|
240
|
+
#mix_rbatch_journal_to_logs : true
|
241
|
+
#mix_rbatch_journal_to_logs : false
|
238
242
|
|
239
243
|
# -------------------
|
240
244
|
# Log setting
|
@@ -245,8 +249,8 @@ Sample of RBatch Run-Conf `${RB_HOME}/.rbatchrc`.
|
|
245
249
|
# Default is "<home>/log"
|
246
250
|
# <home> is replaced to ${RB_HOME}
|
247
251
|
#
|
248
|
-
#log_dir: <home>/rb_log
|
249
|
-
#log_dir: /var/log/rbatch/
|
252
|
+
#log_dir : <home>/rb_log
|
253
|
+
#log_dir : /var/log/rbatch/
|
250
254
|
|
251
255
|
# Log File Name
|
252
256
|
#
|
@@ -272,12 +276,9 @@ Sample of RBatch Run-Conf `${RB_HOME}/.rbatchrc`.
|
|
272
276
|
# Effective values are "debug","info","wran","error",and "fatal".
|
273
277
|
#
|
274
278
|
#log_level : "debug"
|
275
|
-
#log_level : "info"
|
276
279
|
#log_level : "warn"
|
277
|
-
#log_level : "error"
|
278
|
-
#log_level : "fatal"
|
279
280
|
|
280
|
-
# Print log string both file and STDOUT
|
281
|
+
# Print log string both log file and STDOUT
|
281
282
|
#
|
282
283
|
# Default is false.
|
283
284
|
#
|
@@ -291,16 +292,16 @@ Sample of RBatch Run-Conf `${RB_HOME}/.rbatchrc`.
|
|
291
292
|
# A log file to delete is a log file which was made by the
|
292
293
|
# RBatch::Log instance, and log filename format include "<date>".
|
293
294
|
#
|
294
|
-
#log_delete_old_log: true
|
295
|
-
#log_delete_old_log: false
|
295
|
+
#log_delete_old_log : true
|
296
|
+
#log_delete_old_log : false
|
296
297
|
|
297
|
-
#
|
298
|
+
# Expire Date of Log Files
|
298
299
|
#
|
299
300
|
# Default is 7.
|
300
301
|
#
|
301
|
-
#log_delete_old_log_date: 14
|
302
|
+
#log_delete_old_log_date : 14
|
302
303
|
|
303
|
-
# Send
|
304
|
+
# Send Mail
|
304
305
|
#
|
305
306
|
# Default is false.
|
306
307
|
# When log.error(msg) or log.fatal(msg) called , send e-mail
|
@@ -308,31 +309,31 @@ Sample of RBatch Run-Conf `${RB_HOME}/.rbatchrc`.
|
|
308
309
|
#
|
309
310
|
#log_send_mail : true
|
310
311
|
|
311
|
-
# Mail
|
312
|
+
# Mail Parameters
|
312
313
|
#
|
313
314
|
#log_mail_to : "xxx@sample.com"
|
314
315
|
#log_mail_from : "xxx@sample.com"
|
315
316
|
#log_mail_server_host : "localhost"
|
316
317
|
#log_mail_server_port : 25
|
317
318
|
|
318
|
-
#
|
319
|
+
# -------------------
|
320
|
+
# Cmd setting
|
321
|
+
# -------------------
|
322
|
+
|
323
|
+
# Raise Exception
|
319
324
|
#
|
320
|
-
# Default is
|
321
|
-
# If
|
322
|
-
# If 0, put nothing.
|
323
|
-
# Example of journal essages are follows.
|
324
|
-
# [RBatch] Load Config : "../conf/hoge.yaml"
|
325
|
+
# Default is false.
|
326
|
+
# If true, when command exit status is not 0, raise exception.
|
325
327
|
#
|
326
|
-
#
|
327
|
-
#
|
328
|
+
#cmd_raise : true
|
329
|
+
#cmd_raise : false
|
328
330
|
|
329
|
-
#
|
331
|
+
# Command Timeout
|
330
332
|
#
|
331
|
-
# Default is
|
332
|
-
# If true, mix RBatch journal messages to log file(s) which is(are) opened at time.
|
333
|
+
# Default is 0 [sec] (=no timeout).
|
333
334
|
#
|
334
|
-
#
|
335
|
-
|
335
|
+
#cmd_timeout : 5
|
336
|
+
|
336
337
|
|
337
338
|
```
|
338
339
|
|
@@ -340,7 +341,9 @@ Sample of RBatch Run-Conf `${RB_HOME}/.rbatchrc`.
|
|
340
341
|
|
341
342
|
If you want to change options in a script, you pass an options object to the constructor of RBatch::Log or RBatch::Cmd.
|
342
343
|
|
343
|
-
#### option of RBatch::Log
|
344
|
+
#### option of RBatch::Log
|
345
|
+
|
346
|
+
Sumple
|
344
347
|
|
345
348
|
opt = {
|
346
349
|
:name => "<date>_<time>_<prog>.log",
|
@@ -360,11 +363,13 @@ If you want to change options in a script, you pass an options object to the con
|
|
360
363
|
|
361
364
|
#### option of RBatch::Cmd
|
362
365
|
|
366
|
+
Sample
|
367
|
+
|
363
368
|
opt = {
|
364
369
|
:raise => false,
|
365
370
|
:timeout => 0
|
366
371
|
}
|
367
|
-
RBatch::Log.new(
|
372
|
+
RBatch::Log.new("ls -l", opt)
|
368
373
|
|
369
374
|
|
370
375
|
Migration from version 1 to version 2
|