bizside 2.3.5 → 2.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bizside/cron_validator.rb +23 -5
- data/lib/bizside/job_utils.rb +17 -1
- data/lib/bizside/version.rb +1 -1
- metadata +3 -4
- data/lib/bizside/log_analyzer.rb +0 -122
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e862771bbdfb64ff2afb022531b1250695b8741628eeefbb1e3b04df397cdda
|
4
|
+
data.tar.gz: e1d399959f57b304de4decd054d21d45e9918bdd8f04a6f78f14e6aa53132827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d047094b8f553a82da8ddc19b76dad83cf53b75241614fa29a52213d14d2cb2c20bf1f889f5b663dbc0c56889b40a65c314fa51f89605bae429c79f18359357f
|
7
|
+
data.tar.gz: e79df9ac71b7c9d7e3bc6df57108fdefadbc9a43bfe5b45181b736880f57c757a3006e9596b336c7418b1fe2e9041467b769de11dfb0b5dd83d4f466a14866c7
|
@@ -30,7 +30,7 @@ module Bizside
|
|
30
30
|
|
31
31
|
def valid_#{attr}?
|
32
32
|
valid_format?(@#{attr}) &&
|
33
|
-
|
33
|
+
valid_range_and_step?(MIN_#{attr.upcase}, MAX_#{attr.upcase}, @#{attr})
|
34
34
|
end
|
35
35
|
EOS
|
36
36
|
end
|
@@ -41,22 +41,40 @@ module Bizside
|
|
41
41
|
value =~ /\A(\*(\/\d+)?|\d+(,\d+)*(-\d+)*(\/\d+)*)\Z/
|
42
42
|
end
|
43
43
|
|
44
|
+
def valid_range_and_step?(min, max, value)
|
45
|
+
valid_range?(min, max, value) && valid_step?(min, max, value)
|
46
|
+
end
|
47
|
+
|
44
48
|
def valid_range?(min, max, value)
|
45
|
-
|
46
|
-
|
49
|
+
range_values = get_range_value(value).split(",")
|
50
|
+
range_values.reject do |v|
|
47
51
|
if v.include?("-")
|
48
52
|
range_v = v.split("-")
|
49
53
|
(min..max).include?(range_v[0].to_i) &&
|
50
54
|
(min..max).include?(range_v[1].to_i) &&
|
51
55
|
range_v[0].to_i < range_v[1].to_i
|
52
56
|
else
|
53
|
-
(min..max).include?
|
57
|
+
(min..max).include?(v.to_i)
|
54
58
|
end
|
55
59
|
end.empty?
|
56
60
|
end
|
57
61
|
|
58
|
-
def
|
62
|
+
def valid_step?(min, max, value)
|
63
|
+
v = get_step_value(value)
|
64
|
+
return true if v.empty?
|
65
|
+
|
66
|
+
v != '*' &&
|
67
|
+
v.to_i != 0 &&
|
68
|
+
(min..max).include?(v.to_i)
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_range_value(value)
|
59
72
|
value.gsub(/(\/\d*|\*)/, "")
|
60
73
|
end
|
74
|
+
|
75
|
+
def get_step_value(value)
|
76
|
+
return "" unless value.include?('/')
|
77
|
+
value.gsub(/.*\/(.*)/) { $1 }
|
78
|
+
end
|
61
79
|
end
|
62
80
|
end
|
data/lib/bizside/job_utils.rb
CHANGED
@@ -173,9 +173,11 @@ module Bizside
|
|
173
173
|
if cronline.to_s.strip.empty?
|
174
174
|
return
|
175
175
|
elsif CronValidator.new(cronline).valid?
|
176
|
+
new_cron = set_cron_options(cron)
|
177
|
+
|
176
178
|
config = {
|
177
179
|
:class => job_type,
|
178
|
-
:cron =>
|
180
|
+
:cron => new_cron,
|
179
181
|
:args => args,
|
180
182
|
:persist => true
|
181
183
|
}
|
@@ -404,5 +406,19 @@ module Bizside
|
|
404
406
|
end
|
405
407
|
private_class_method :do_perform_and_hooks_instantly
|
406
408
|
|
409
|
+
def self.set_cron_options(cron)
|
410
|
+
ret = Array(cron)
|
411
|
+
if ret.size > 1
|
412
|
+
opts = ret.second
|
413
|
+
opts ||= {}
|
414
|
+
opts = opts.with_indifferent_access
|
415
|
+
opts = opts.merge(blocking: true)
|
416
|
+
else
|
417
|
+
opts = { blocking: true }.with_indifferent_access
|
418
|
+
end
|
419
|
+
ret[1] = opts
|
420
|
+
ret
|
421
|
+
end
|
422
|
+
|
407
423
|
end
|
408
424
|
end
|
data/lib/bizside/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bizside
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bizside-developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -413,7 +413,6 @@ files:
|
|
413
413
|
- lib/bizside/implicit_ftps.rb
|
414
414
|
- lib/bizside/itamae_conf.rb
|
415
415
|
- lib/bizside/job_utils.rb
|
416
|
-
- lib/bizside/log_analyzer.rb
|
417
416
|
- lib/bizside/mailer.rb
|
418
417
|
- lib/bizside/query_builder.rb
|
419
418
|
- lib/bizside/railtie.rb
|
@@ -476,7 +475,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
476
475
|
- !ruby/object:Gem::Version
|
477
476
|
version: '0'
|
478
477
|
requirements: []
|
479
|
-
rubygems_version: 3.
|
478
|
+
rubygems_version: 3.4.19
|
480
479
|
signing_key:
|
481
480
|
specification_version: 4
|
482
481
|
summary: Bizside is an utilities for web application.
|
data/lib/bizside/log_analyzer.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
module Bizside
|
2
|
-
class LogAnalyzer
|
3
|
-
attr_reader :add_on_name
|
4
|
-
attr_reader :error_contents
|
5
|
-
|
6
|
-
def initialize(add_on_name, files)
|
7
|
-
@add_on_name = add_on_name
|
8
|
-
@files = files
|
9
|
-
end
|
10
|
-
|
11
|
-
def analyze(output_file_name)
|
12
|
-
@success = system("request-log-analyzer --format rails3 --parse-strategy cautious --file #{output_file_name}.html --output HTML #{@files.join(' ')}")
|
13
|
-
end
|
14
|
-
|
15
|
-
def success?
|
16
|
-
@success
|
17
|
-
end
|
18
|
-
|
19
|
-
def scrape_errors
|
20
|
-
@error_content = String.new
|
21
|
-
@error_contents = {}
|
22
|
-
|
23
|
-
# TODO Okozeを解析できるようにする
|
24
|
-
return if add_on_name == 'okoze'
|
25
|
-
|
26
|
-
# TODO ログ内で重複したエラーメッセージを除外する
|
27
|
-
return if ['amadai', 'webcam_api', 'seri', 'sushioke'].include?(add_on_name)
|
28
|
-
|
29
|
-
@files.each do |file|
|
30
|
-
content = File.read(file, encoding: 'utf-8')
|
31
|
-
content = content.encode('UTF-16BE', 'UTF-8', :invalid => :replace, :undef => :replace, :replace => '?').encode('UTF-8')
|
32
|
-
next unless content.include?('Completed 500') or content.include?('FATAL')
|
33
|
-
|
34
|
-
# ログをプロセス単位に分割
|
35
|
-
partition_contents = divide_into_pid(content)
|
36
|
-
# プロセス単位に分割したログからエラーを抽出
|
37
|
-
partition_content_errors = extract_error_log(partition_contents)
|
38
|
-
# 抽出したエラーを出力用にまとめる
|
39
|
-
partition_content_errors.each do |pid, pc|
|
40
|
-
@error_contents[pid] = "#{file}のエラー抽出結果\n\n\n" if @error_contents[pid].nil? or @error_contents[pid].empty?
|
41
|
-
@error_contents[pid] << pc
|
42
|
-
end
|
43
|
-
|
44
|
-
@error_contents
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def divide_into_pid(content)
|
49
|
-
pid = nil
|
50
|
-
ret = {}
|
51
|
-
content.each_line do |c|
|
52
|
-
s = c.scan(/#[0-9]+\]/)
|
53
|
-
pid = s.first.scan(/[0-9]+/).first unless s.empty?
|
54
|
-
ret[pid] = "" unless ret[pid]
|
55
|
-
ret[pid] << c
|
56
|
-
end
|
57
|
-
|
58
|
-
ret
|
59
|
-
end
|
60
|
-
|
61
|
-
def extract_error_log(partition_contents)
|
62
|
-
ret = {}
|
63
|
-
partition_contents.each do |pid, pc|
|
64
|
-
tmp = ""
|
65
|
-
pc.each_line do |line|
|
66
|
-
unless line.scan(/: Started /).empty?
|
67
|
-
if !tmp.scan(/Completed 500/).empty? or !tmp.scan(/\] FATAL/).empty? or !tmp.scan(/\[FATAL\]/).empty?
|
68
|
-
ret[pid] = "" if ret[pid].nil? or ret[pid].empty?
|
69
|
-
ret[pid] << tmp
|
70
|
-
end
|
71
|
-
tmp.clear
|
72
|
-
end
|
73
|
-
tmp << exclude_error_log_line(line)
|
74
|
-
end
|
75
|
-
|
76
|
-
# Startedの前にログが終了した場合、その時点までにエラーが含まれていれば抽出に含める
|
77
|
-
if !tmp.empty? and !tmp.scan(/Completed 500/).empty? or !tmp.scan(/\] FATAL/).empty? or !tmp.scan(/\[FATAL\]/).empty?
|
78
|
-
ret[pid] = "" if ret[pid].nil? or ret[pid].empty?
|
79
|
-
ret[pid] << tmp
|
80
|
-
end
|
81
|
-
tmp.clear
|
82
|
-
end
|
83
|
-
|
84
|
-
ret
|
85
|
-
end
|
86
|
-
|
87
|
-
def exclude_error_log_line(line)
|
88
|
-
ret = nil
|
89
|
-
ret = line.match("INFO -- : ジョブ.*登録します。")
|
90
|
-
|
91
|
-
if ret.nil?
|
92
|
-
line
|
93
|
-
else
|
94
|
-
""
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# TODO 重複したエラーログを除外する
|
99
|
-
def get_duplicate_check_line(line)
|
100
|
-
ret = line.scan(/(INFO -- :.*|ERROR -- :.*|WARN -- :.*|FATAL -- :.*)/).first
|
101
|
-
ret = ret.gsub(/\" for .*/, "\"") unless ret.nil or ret.empty?
|
102
|
-
|
103
|
-
ret
|
104
|
-
end
|
105
|
-
|
106
|
-
# TODO 重複したエラーログを除外する
|
107
|
-
def duplicate_error_log?(extract_error_logs, duplicate_check_lines)
|
108
|
-
res = false
|
109
|
-
extract_error_logs.each do |eer|
|
110
|
-
tmp = false
|
111
|
-
duplicate_check_lines.each do |dcl|
|
112
|
-
tmp = eer.include?(dcl)
|
113
|
-
break unless tmp
|
114
|
-
end
|
115
|
-
res = tmp
|
116
|
-
break if res
|
117
|
-
end
|
118
|
-
|
119
|
-
res
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|