bizside 2.0.7 → 2.0.8
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.
- checksums.yaml +4 -4
- data/lib/bizside/task_helper.rb +2 -2
- data/lib/bizside/uploader/content_type_validator.rb +1 -1
- data/lib/bizside/user_agent/action_view/action_view_4.rb +1 -1
- data/lib/bizside/version.rb +1 -1
- data/validations/tel_validator.rb +28 -28
- data/validations/zip_validator.rb +35 -35
- metadata +21 -24
- data/lib/bizside/resque.rb.bkp +0 -161
- data/lib/bizside/resque.rb~ +0 -154
- data/lib/bizside/version.rb~ +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9689c1f6e742e9512e144312cdd80ab20e968b75780eee36b4211996f00f26a1
|
4
|
+
data.tar.gz: 6642f8337d4a1db6f55505278374888e87a198b882b3c0386ddddf1b5886bf8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ae3c04ced97b0d14a52d5db5f03bb52a30cb1cd1d7fa743ce569b7af957949f42b4fa89ad8274e7eb09a026a6aa9a27af817c02e6d89b8ca909a4c84cfe75e6
|
7
|
+
data.tar.gz: 41c281d34b047bbece294070e4bd64ee5868a797cb7ac1422ce5565e99bbe9d2fea34a78b3dcdfd0f4342cae83a6f626419b0b502dc1949a0570177a7e407bfd
|
data/lib/bizside/task_helper.rb
CHANGED
@@ -176,7 +176,7 @@ end
|
|
176
176
|
|
177
177
|
def self.ask_env(env_key, options = {})
|
178
178
|
cache_file = 'tmp/cache/env'
|
179
|
-
cache = File.
|
179
|
+
cache = File.exist?(cache_file) ? YAML.load_file(cache_file) : {}
|
180
180
|
|
181
181
|
if options.fetch(:cache, false)
|
182
182
|
options = options.merge(default: cache.fetch(env_key, options[:default]))
|
@@ -190,7 +190,7 @@ def self.ask_env(env_key, options = {})
|
|
190
190
|
cache[env_key] = ENV[env_key]
|
191
191
|
File.write(cache_file, YAML.dump(cache))
|
192
192
|
else
|
193
|
-
if File.
|
193
|
+
if File.exist?(cache_file) and cache[env_key]
|
194
194
|
cache.delete(env_key)
|
195
195
|
File.write(cache_file, YAML.dump(cache))
|
196
196
|
end
|
@@ -10,7 +10,7 @@ module Bizside
|
|
10
10
|
require 'carrierwave-magic'
|
11
11
|
include CarrierWave::Magic
|
12
12
|
process :set_magic_content_type => true
|
13
|
-
rescue
|
13
|
+
rescue
|
14
14
|
raise '[Bizside.gem ERROR] you need to add carrierwave-magic.gem.'
|
15
15
|
end
|
16
16
|
before :cache, :validate_content_type!
|
data/lib/bizside/version.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
# 電話番号のバリデーション
|
2
|
-
# ActiveModel::EachValidatorを継承してRailsに統合する
|
3
|
-
class TelValidator < ActiveModel::EachValidator
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
super(options)
|
7
|
-
end
|
8
|
-
|
9
|
-
# レコード保存時に呼び出されるバリデーションメソッド
|
10
|
-
# record ・・・ 保存対象のレコード
|
11
|
-
# attribute ・・・ チェック対象の属性(DBのカラム)
|
12
|
-
# value ・・・ 入力された値
|
13
|
-
def validate_each(record, attribute, value)
|
14
|
-
return if value.nil? or value.empty?
|
15
|
-
|
16
|
-
unless validate_tel(record, value)
|
17
|
-
record.errors[attribute] << I18n.t('errors.messages.invalid')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
# 電話番号として妥当かどうかのチェック
|
24
|
-
def validate_tel(record, value)
|
25
|
-
# 全角・半角とわず数字とハイフンの構成であれば良しとしている
|
26
|
-
value.match(/^[0-9|0-9]+[-|-]?[0-9|0-9]+[-|-]?[0-9|0-9]+$/)
|
27
|
-
end
|
28
|
-
end
|
1
|
+
# 電話番号のバリデーション
|
2
|
+
# ActiveModel::EachValidatorを継承してRailsに統合する
|
3
|
+
class TelValidator < ActiveModel::EachValidator
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
super(options)
|
7
|
+
end
|
8
|
+
|
9
|
+
# レコード保存時に呼び出されるバリデーションメソッド
|
10
|
+
# record ・・・ 保存対象のレコード
|
11
|
+
# attribute ・・・ チェック対象の属性(DBのカラム)
|
12
|
+
# value ・・・ 入力された値
|
13
|
+
def validate_each(record, attribute, value)
|
14
|
+
return if value.nil? or value.empty?
|
15
|
+
|
16
|
+
unless validate_tel(record, value)
|
17
|
+
record.errors[attribute] << I18n.t('errors.messages.invalid')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# 電話番号として妥当かどうかのチェック
|
24
|
+
def validate_tel(record, value)
|
25
|
+
# 全角・半角とわず数字とハイフンの構成であれば良しとしている
|
26
|
+
value.match(/^[0-9|0-9]+[-|-]?[0-9|0-9]+[-|-]?[0-9|0-9]+$/)
|
27
|
+
end
|
28
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
class ZipValidator < ActiveModel::EachValidator
|
2
|
-
|
3
|
-
def initialize(options = {})
|
4
|
-
super(options)
|
5
|
-
@other = options[:other]
|
6
|
-
end
|
7
|
-
|
8
|
-
def validate_each(record, attribute, value)
|
9
|
-
zip1 = value
|
10
|
-
zip2 = get_other_value(record)
|
11
|
-
|
12
|
-
return if (zip1.nil? or zip1.empty?) and (zip2.nil? or zip2.empty?)
|
13
|
-
|
14
|
-
unless validate_zip(zip1, zip2)
|
15
|
-
record.errors[attribute] << I18n.t('errors.messages.zip')
|
16
|
-
return
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def validate_zip(zip1, zip2)
|
23
|
-
return false unless zip1
|
24
|
-
return false unless zip1.match(/^[0-9|0-9]{3}$/)
|
25
|
-
|
26
|
-
return false unless zip2
|
27
|
-
return false unless zip2.match(/^[0-9|0-9]{4}$/)
|
28
|
-
|
29
|
-
true
|
30
|
-
end
|
31
|
-
|
32
|
-
def get_other_value(record)
|
33
|
-
record.__send__(@other)
|
34
|
-
end
|
35
|
-
end
|
1
|
+
class ZipValidator < ActiveModel::EachValidator
|
2
|
+
|
3
|
+
def initialize(options = {})
|
4
|
+
super(options)
|
5
|
+
@other = options[:other]
|
6
|
+
end
|
7
|
+
|
8
|
+
def validate_each(record, attribute, value)
|
9
|
+
zip1 = value
|
10
|
+
zip2 = get_other_value(record)
|
11
|
+
|
12
|
+
return if (zip1.nil? or zip1.empty?) and (zip2.nil? or zip2.empty?)
|
13
|
+
|
14
|
+
unless validate_zip(zip1, zip2)
|
15
|
+
record.errors[attribute] << I18n.t('errors.messages.zip')
|
16
|
+
return
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def validate_zip(zip1, zip2)
|
23
|
+
return false unless zip1
|
24
|
+
return false unless zip1.match(/^[0-9|0-9]{3}$/)
|
25
|
+
|
26
|
+
return false unless zip2
|
27
|
+
return false unless zip2.match(/^[0-9|0-9]{4}$/)
|
28
|
+
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_other_value(record)
|
33
|
+
record.__send__(@other)
|
34
|
+
end
|
35
|
+
end
|
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.0.
|
4
|
+
version: 2.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bizside-developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -160,16 +160,22 @@ dependencies:
|
|
160
160
|
name: rake
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
|
-
- - "
|
163
|
+
- - ">="
|
164
164
|
- !ruby/object:Gem::Version
|
165
165
|
version: '12.3'
|
166
|
+
- - "<"
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '14.0'
|
166
169
|
type: :runtime
|
167
170
|
prerelease: false
|
168
171
|
version_requirements: !ruby/object:Gem::Requirement
|
169
172
|
requirements:
|
170
|
-
- - "
|
173
|
+
- - ">="
|
171
174
|
- !ruby/object:Gem::Version
|
172
175
|
version: '12.3'
|
176
|
+
- - "<"
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '14.0'
|
173
179
|
- !ruby/object:Gem::Dependency
|
174
180
|
name: RedCloth
|
175
181
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,7 +199,7 @@ dependencies:
|
|
193
199
|
version: '3.0'
|
194
200
|
- - "<"
|
195
201
|
- !ruby/object:Gem::Version
|
196
|
-
version: '3.
|
202
|
+
version: '3.36'
|
197
203
|
type: :development
|
198
204
|
prerelease: false
|
199
205
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -203,27 +209,21 @@ dependencies:
|
|
203
209
|
version: '3.0'
|
204
210
|
- - "<"
|
205
211
|
- !ruby/object:Gem::Version
|
206
|
-
version: '3.
|
212
|
+
version: '3.36'
|
207
213
|
- !ruby/object:Gem::Dependency
|
208
214
|
name: cucumber
|
209
215
|
requirement: !ruby/object:Gem::Requirement
|
210
216
|
requirements:
|
211
|
-
- - "
|
212
|
-
- !ruby/object:Gem::Version
|
213
|
-
version: '2.4'
|
214
|
-
- - "<"
|
217
|
+
- - "~>"
|
215
218
|
- !ruby/object:Gem::Version
|
216
|
-
version: '
|
219
|
+
version: '7.1'
|
217
220
|
type: :development
|
218
221
|
prerelease: false
|
219
222
|
version_requirements: !ruby/object:Gem::Requirement
|
220
223
|
requirements:
|
221
|
-
- - "
|
222
|
-
- !ruby/object:Gem::Version
|
223
|
-
version: '2.4'
|
224
|
-
- - "<"
|
224
|
+
- - "~>"
|
225
225
|
- !ruby/object:Gem::Version
|
226
|
-
version: '
|
226
|
+
version: '7.1'
|
227
227
|
- !ruby/object:Gem::Dependency
|
228
228
|
name: cucumber-rails
|
229
229
|
requirement: !ruby/object:Gem::Requirement
|
@@ -350,22 +350,22 @@ dependencies:
|
|
350
350
|
name: sqlite3
|
351
351
|
requirement: !ruby/object:Gem::Requirement
|
352
352
|
requirements:
|
353
|
-
- - "
|
353
|
+
- - ">="
|
354
354
|
- !ruby/object:Gem::Version
|
355
355
|
version: '1.3'
|
356
356
|
- - "<"
|
357
357
|
- !ruby/object:Gem::Version
|
358
|
-
version: 1.
|
358
|
+
version: 1.5.0
|
359
359
|
type: :development
|
360
360
|
prerelease: false
|
361
361
|
version_requirements: !ruby/object:Gem::Requirement
|
362
362
|
requirements:
|
363
|
-
- - "
|
363
|
+
- - ">="
|
364
364
|
- !ruby/object:Gem::Version
|
365
365
|
version: '1.3'
|
366
366
|
- - "<"
|
367
367
|
- !ruby/object:Gem::Version
|
368
|
-
version: 1.
|
368
|
+
version: 1.5.0
|
369
369
|
description: Bizside is an utilities to assist building web application.
|
370
370
|
email:
|
371
371
|
- bizside-developers@lab.acs-jp.com
|
@@ -419,8 +419,6 @@ files:
|
|
419
419
|
- lib/bizside/railtie.rb
|
420
420
|
- lib/bizside/record_has_warnings.rb
|
421
421
|
- lib/bizside/resque.rb
|
422
|
-
- lib/bizside/resque.rb.bkp
|
423
|
-
- lib/bizside/resque.rb~
|
424
422
|
- lib/bizside/rsync.rb
|
425
423
|
- lib/bizside/safe_pty.rb
|
426
424
|
- lib/bizside/shib_utils.rb
|
@@ -443,7 +441,6 @@ files:
|
|
443
441
|
- lib/bizside/user_agent/controller_helper.rb
|
444
442
|
- lib/bizside/validations.rb
|
445
443
|
- lib/bizside/version.rb
|
446
|
-
- lib/bizside/version.rb~
|
447
444
|
- lib/bizside/view_helper.rb
|
448
445
|
- lib/bizside/warning.rb
|
449
446
|
- lib/bizside/yes.rb
|
@@ -482,7 +479,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
482
479
|
- !ruby/object:Gem::Version
|
483
480
|
version: '0'
|
484
481
|
requirements: []
|
485
|
-
rubygems_version: 3.
|
482
|
+
rubygems_version: 3.3.10
|
486
483
|
signing_key:
|
487
484
|
specification_version: 4
|
488
485
|
summary: Bizside is an utilities for web application.
|
data/lib/bizside/resque.rb.bkp
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
module Bizside
|
2
|
-
module Resque
|
3
|
-
end
|
4
|
-
end
|
5
|
-
|
6
|
-
require 'resque'
|
7
|
-
require 'resque/worker'
|
8
|
-
require 'resque/failure/base'
|
9
|
-
require 'resque/failure/multiple'
|
10
|
-
require 'resque/failure/redis'
|
11
|
-
require_relative 'audit/job_logger'
|
12
|
-
|
13
|
-
{
|
14
|
-
yaml: ['config/resque.yml', 'config/redis.yml'],
|
15
|
-
json: ['config/resque.json', 'config/redis.json']
|
16
|
-
}.each do |format, file_candidates|
|
17
|
-
file_candidates.each do |file|
|
18
|
-
resque_file = File.join(File.expand_path(ENV['RAILS_ROOT'] || '.'), file)
|
19
|
-
next unless File.exist?(resque_file)
|
20
|
-
|
21
|
-
resque_config = ERB.new(File.read(resque_file), 0, '-').result
|
22
|
-
|
23
|
-
case format
|
24
|
-
when :yaml
|
25
|
-
Resque.redis = YAML.load(resque_config)[Bizside.env]
|
26
|
-
break
|
27
|
-
when :json
|
28
|
-
Resque.redis = ActiveSupport::JSON.decode(resque_config)[Bizside.env]
|
29
|
-
break
|
30
|
-
else
|
31
|
-
raise "不正なResque設定ファイルです。#{file}"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
Resque.redis.namespace = "resque:#{Bizside.config.add_on_name}:#{Bizside.env}"
|
37
|
-
|
38
|
-
if defined?(Resque::Scheduler)
|
39
|
-
Resque::Scheduler.dynamic = true
|
40
|
-
end
|
41
|
-
|
42
|
-
# tmp/stop.txt が存在する場合は一時停止する
|
43
|
-
module Resque
|
44
|
-
class Worker
|
45
|
-
|
46
|
-
alias_method :reserve_without_stop_txt, :reserve
|
47
|
-
|
48
|
-
def reserve
|
49
|
-
stop_file_path = File.join('tmp', 'stop.txt')
|
50
|
-
if File.exist?(stop_file_path)
|
51
|
-
puts "#{Resque.redis.namespace} #{stop_file_path} が存在するため一時停止します。"
|
52
|
-
nil
|
53
|
-
else
|
54
|
-
reserve_without_stop_txt
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# resque-webのエラーメッセージ文字化けに対するパッチ
|
62
|
-
module Resque
|
63
|
-
module Failure
|
64
|
-
class Redis
|
65
|
-
|
66
|
-
def save
|
67
|
-
data = {
|
68
|
-
:failed_at => UTF8Util.clean(Time.now.strftime("%Y/%m/%d %H:%M:%S %Z")),
|
69
|
-
:payload => payload,
|
70
|
-
:exception => exception.class.to_s,
|
71
|
-
:error => exception.to_s, #UTF8Util.clean(exception.to_s), UTF8Util.cleanを呼ぶと文字化けする
|
72
|
-
:backtrace => filter_backtrace(Array(exception.backtrace)),
|
73
|
-
:worker => worker.to_s,
|
74
|
-
:queue => queue
|
75
|
-
}
|
76
|
-
data = Resque.encode(data)
|
77
|
-
Resque.redis.rpush(:failed, data)
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# エラーをログに出力
|
85
|
-
module Resque
|
86
|
-
module Failure
|
87
|
-
class LogOutput < Base
|
88
|
-
def save
|
89
|
-
Bizside.logger.error [
|
90
|
-
"[FATAL] Resque #{queue}:#{worker}",
|
91
|
-
"#{payload}",
|
92
|
-
"#{exception.class} #{exception.to_s}",
|
93
|
-
"#{Array(exception.backtrace).join("\n")}"
|
94
|
-
].join("\n")
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
# エラーをLTSV形式で専用ログに出力
|
101
|
-
module Resque
|
102
|
-
module Failure
|
103
|
-
class JobAuditLog < Base
|
104
|
-
|
105
|
-
def save
|
106
|
-
dump_env
|
107
|
-
info = build_loginfo
|
108
|
-
return info if Bizside.rails_env&.test?
|
109
|
-
|
110
|
-
logger.record(info)
|
111
|
-
|
112
|
-
info
|
113
|
-
end
|
114
|
-
|
115
|
-
private
|
116
|
-
|
117
|
-
def logger
|
118
|
-
@logger ||= Bizside::Audit::JobLogger.logger
|
119
|
-
end
|
120
|
-
|
121
|
-
def build_loginfo
|
122
|
-
info = {
|
123
|
-
time: Time.now.strftime('%Y-%m-%dT%H:%M:%S.%3N%z'),
|
124
|
-
add_on_name: Bizside.config.add_on_name,
|
125
|
-
server_address: hostname,
|
126
|
-
class: payload['class'],
|
127
|
-
args: payload['args'].to_s,
|
128
|
-
queue: queue,
|
129
|
-
worker: worker.to_s,
|
130
|
-
exception: exception.class,
|
131
|
-
exception_message: exception.to_s,
|
132
|
-
exception_backtrace: Array(exception.backtrace)[0..10].join("\n") # Get only the top 10 because there are many traces.
|
133
|
-
}
|
134
|
-
info
|
135
|
-
end
|
136
|
-
|
137
|
-
|
138
|
-
def dump_env
|
139
|
-
File.open('/tmp/resque-dump.log', 'a') do |f|
|
140
|
-
f.puts('== begin')
|
141
|
-
for k, v in ENV do
|
142
|
-
f.printf("%30s %s\n", k, v)
|
143
|
-
end
|
144
|
-
f.puts('')
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
# hostname(1) からホスト名を取得。
|
149
|
-
#
|
150
|
-
# job 実行環境(コンテナ等)では環境変数(HOSTNAME等)にホスト名はセットされていない。
|
151
|
-
def hostname
|
152
|
-
@hostname ||= (`hostname`.chomp rescue '(unknown)')
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
Resque::Failure::Multiple.configure do |multi|
|
160
|
-
multi.classes = [Resque::Failure::Redis, Resque::Failure::LogOutput, Resque::Failure::JobAuditLog]
|
161
|
-
end
|
data/lib/bizside/resque.rb~
DELETED
@@ -1,154 +0,0 @@
|
|
1
|
-
module Bizside
|
2
|
-
module Resque
|
3
|
-
end
|
4
|
-
end
|
5
|
-
|
6
|
-
require 'resque'
|
7
|
-
require 'resque/worker'
|
8
|
-
require 'resque/failure/base'
|
9
|
-
require 'resque/failure/multiple'
|
10
|
-
require 'resque/failure/redis'
|
11
|
-
require_relative 'audit/job_logger'
|
12
|
-
|
13
|
-
{
|
14
|
-
yaml: ['config/resque.yml', 'config/redis.yml'],
|
15
|
-
json: ['config/resque.json', 'config/redis.json']
|
16
|
-
}.each do |format, file_candidates|
|
17
|
-
file_candidates.each do |file|
|
18
|
-
resque_file = File.join(File.expand_path(ENV['RAILS_ROOT'] || '.'), file)
|
19
|
-
next unless File.exist?(resque_file)
|
20
|
-
|
21
|
-
resque_config = ERB.new(File.read(resque_file), 0, '-').result
|
22
|
-
|
23
|
-
case format
|
24
|
-
when :yaml
|
25
|
-
Resque.redis = YAML.load(resque_config)[Bizside.env]
|
26
|
-
break
|
27
|
-
when :json
|
28
|
-
Resque.redis = ActiveSupport::JSON.decode(resque_config)[Bizside.env]
|
29
|
-
break
|
30
|
-
else
|
31
|
-
raise "不正なResque設定ファイルです。#{file}"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
Resque.redis.namespace = "resque:#{Bizside.config.add_on_name}:#{Bizside.env}"
|
37
|
-
|
38
|
-
if defined?(Resque::Scheduler)
|
39
|
-
Resque::Scheduler.dynamic = true
|
40
|
-
end
|
41
|
-
|
42
|
-
# tmp/stop.txt が存在する場合は一時停止する
|
43
|
-
module Resque
|
44
|
-
class Worker
|
45
|
-
|
46
|
-
alias_method :reserve_without_stop_txt, :reserve
|
47
|
-
|
48
|
-
def reserve
|
49
|
-
stop_file_path = File.join('tmp', 'stop.txt')
|
50
|
-
if File.exist?(stop_file_path)
|
51
|
-
puts "#{Resque.redis.namespace} #{stop_file_path} が存在するため一時停止します。"
|
52
|
-
nil
|
53
|
-
else
|
54
|
-
reserve_without_stop_txt
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# resque-webのエラーメッセージ文字化けに対するパッチ
|
62
|
-
module Resque
|
63
|
-
module Failure
|
64
|
-
class Redis
|
65
|
-
|
66
|
-
def save
|
67
|
-
data = {
|
68
|
-
:failed_at => UTF8Util.clean(Time.now.strftime("%Y/%m/%d %H:%M:%S %Z")),
|
69
|
-
:payload => payload,
|
70
|
-
:exception => exception.class.to_s,
|
71
|
-
:error => exception.to_s, #UTF8Util.clean(exception.to_s), UTF8Util.cleanを呼ぶと文字化けする
|
72
|
-
:backtrace => filter_backtrace(Array(exception.backtrace)),
|
73
|
-
:worker => worker.to_s,
|
74
|
-
:queue => queue
|
75
|
-
}
|
76
|
-
data = Resque.encode(data)
|
77
|
-
Resque.redis.rpush(:failed, data)
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# エラーをログに出力
|
85
|
-
module Resque
|
86
|
-
module Failure
|
87
|
-
class LogOutput < Base
|
88
|
-
def save
|
89
|
-
Bizside.logger.error [
|
90
|
-
"[FATAL] Resque #{queue}:#{worker}",
|
91
|
-
"#{payload}",
|
92
|
-
"#{exception.class} #{exception.to_s}",
|
93
|
-
"#{Array(exception.backtrace).join("\n")}"
|
94
|
-
].join("\n")
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
# エラーをLTSV形式で専用ログに出力
|
101
|
-
module Resque
|
102
|
-
module Failure
|
103
|
-
class JobAuditLog < Base
|
104
|
-
|
105
|
-
def save
|
106
|
-
info = build_loginfo
|
107
|
-
return info if Bizside.rails_env&.test?
|
108
|
-
|
109
|
-
logger.record(info)
|
110
|
-
|
111
|
-
info
|
112
|
-
end
|
113
|
-
|
114
|
-
private
|
115
|
-
|
116
|
-
def logger
|
117
|
-
@logger ||= Bizside::Audit::JobLogger.logger
|
118
|
-
end
|
119
|
-
|
120
|
-
def build_loginfo
|
121
|
-
info = {
|
122
|
-
time: Time.now.strftime('%Y-%m-%dT%H:%M:%S.%3N%z'),
|
123
|
-
add_on_name: Bizside.config.add_on_name,
|
124
|
-
server_address: hostname,
|
125
|
-
class: payload['class'],
|
126
|
-
args: payload['args'].to_s,
|
127
|
-
queue: queue,
|
128
|
-
worker: worker.to_s,
|
129
|
-
exception: exception.class,
|
130
|
-
exception_message: exception.to_s,
|
131
|
-
exception_backtrace: Array(exception.backtrace)[0..10].join("\n") # Get only the top 10 because there are many traces.
|
132
|
-
}
|
133
|
-
info
|
134
|
-
end
|
135
|
-
|
136
|
-
# ホスト名を取得。
|
137
|
-
#
|
138
|
-
# 下記理由から hostname(1) を使用:
|
139
|
-
#
|
140
|
-
# * job 実行環境では環境変数 HOSTNAME がセットされていないケースがある
|
141
|
-
# (例: 通常の god 起動の場合。他方、container 起動の場合は
|
142
|
-
# HOSTNAME がセットされている模様)。
|
143
|
-
# * hostname(1) は Linux Standard Base 共通コマンドのため必ず存在する。
|
144
|
-
def hostname
|
145
|
-
@hostname ||= (`hostname`.chomp rescue '(unknown)')
|
146
|
-
end
|
147
|
-
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
Resque::Failure::Multiple.configure do |multi|
|
153
|
-
multi.classes = [Resque::Failure::Redis, Resque::Failure::LogOutput, Resque::Failure::JobAuditLog]
|
154
|
-
end
|
data/lib/bizside/version.rb~
DELETED