dekiru 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -33
- data/Rakefile +0 -15
- data/dekiru.gemspec +0 -2
- data/lib/dekiru.rb +0 -2
- data/lib/dekiru/railtie.rb +0 -2
- data/lib/dekiru/version.rb +1 -1
- metadata +3 -37
- data/lib/dekiru/configure.rb +0 -14
- data/lib/dekiru/job_mon_client.rb +0 -58
- data/lib/dekiru/rake_monitor.rb +0 -29
- data/lib/dekiru/tasks/delayed_job_queue_check.rake +0 -18
- data/lib/dekiru/tasks/delayed_job_queue_monitor.rake +0 -13
- data/lib/generators/dekiru/dekiru_generator.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 844c73ce0ab637db4415bd31e67ac17afb71323d
|
4
|
+
data.tar.gz: 1be786dc57003ad8ddc2c7937ca70beb3d7ca55b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 855639c15c73a5299c143bb87fce7c71c4d5fa6ecac1f88653d85c46b4fce2c15d4c162ac944767671b421ad26c2aaaade8c35b32dbf8aa42bde349361f2cfcf
|
7
|
+
data.tar.gz: 6e1b89dbf1bf8daf8b02e0d4e2c379f2cca7bd2b7643380ae290c3c9b9d189424821d4b5324bcb9694a7788bc9e1a96df573fba94fb7ff3abccace51184bc6ca
|
data/README.md
CHANGED
@@ -18,38 +18,6 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install dekiru
|
20
20
|
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
以下のコマンドを実行すると、監視のための設定ファイルが自動的に生成される。
|
24
|
-
|
25
|
-
```
|
26
|
-
bin/rails g dekiru
|
27
|
-
```
|
28
|
-
|
29
|
-
メールアドレス、例外時の処理などは必要に応じて変更する。
|
30
|
-
|
31
|
-
```
|
32
|
-
Dekiru.configure do |config|
|
33
|
-
config.monitor_email = "email@example.com"
|
34
|
-
config.monitor_api_key = "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxx"
|
35
|
-
config.error_handle = -> (e) { Bugsnag.notify(e) }
|
36
|
-
end
|
37
|
-
```
|
38
|
-
|
39
|
-
Rakefile にて、'dekiru/rake_monitor' を読み込む。
|
40
|
-
|
41
|
-
```
|
42
|
-
require 'dekiru/rake_monitor'
|
43
|
-
```
|
44
|
-
|
45
|
-
rake で、`task_with_monitor` を使ってタスクを記述することで、 task を監視することができます。
|
46
|
-
|
47
|
-
```
|
48
|
-
task_with_monitor job: :environment, estimate_time: 10 do
|
49
|
-
puts "execute"
|
50
|
-
end
|
51
|
-
```
|
52
|
-
|
53
21
|
## Capybara Helpers
|
54
22
|
|
55
23
|
以下の設定をすると Capybara 用のヘルパーメソッドが使えるようになる。
|
@@ -77,7 +45,6 @@ click_on 'Button in modal'
|
|
77
45
|
```
|
78
46
|
|
79
47
|
|
80
|
-
|
81
48
|
## Contributing
|
82
49
|
|
83
50
|
1. Fork it
|
data/Rakefile
CHANGED
@@ -8,18 +8,3 @@ RSpec::Core::RakeTask.new do |t|
|
|
8
8
|
t.rspec_opts = ['--color', "--format progress"]
|
9
9
|
t.pattern = 'spec/dekiru/**/*_spec.rb'
|
10
10
|
end
|
11
|
-
|
12
|
-
require 'dekiru'
|
13
|
-
require 'dekiru/rake_monitor'
|
14
|
-
|
15
|
-
Dekiru.configure do |config|
|
16
|
-
config.monitor_email = "email@example.com"
|
17
|
-
config.monitor_api_key = "0680fa6b-c014-4985-8d05-1cca2d50512b"
|
18
|
-
config.error_handle = -> (e) {
|
19
|
-
puts e
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
task_with_monitor job: nil, estimate_time: 10 do
|
24
|
-
puts "execute"
|
25
|
-
end
|
data/dekiru.gemspec
CHANGED
@@ -17,8 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.add_dependency 'http_accept_language', [">= 2.0.0"]
|
19
19
|
gem.add_dependency 'rails'
|
20
|
-
gem.add_dependency 'faraday'
|
21
|
-
gem.add_dependency 'faraday_middleware'
|
22
20
|
gem.add_development_dependency 'rake', [">= 0"]
|
23
21
|
gem.add_development_dependency 'rspec'
|
24
22
|
gem.add_development_dependency 'rubocop'
|
data/lib/dekiru.rb
CHANGED
data/lib/dekiru/railtie.rb
CHANGED
data/lib/dekiru/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dekiru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akihiro Matsumura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http_accept_language
|
@@ -38,34 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: faraday
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: faraday_middleware
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: rake
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,18 +111,12 @@ files:
|
|
139
111
|
- dekiru.gemspec
|
140
112
|
- lib/dekiru.rb
|
141
113
|
- lib/dekiru/capybara/helpers.rb
|
142
|
-
- lib/dekiru/configure.rb
|
143
114
|
- lib/dekiru/controller_additions.rb
|
144
115
|
- lib/dekiru/helper.rb
|
145
|
-
- lib/dekiru/job_mon_client.rb
|
146
116
|
- lib/dekiru/railtie.rb
|
147
|
-
- lib/dekiru/rake_monitor.rb
|
148
117
|
- lib/dekiru/smtp_check_mailer.rb
|
149
|
-
- lib/dekiru/tasks/delayed_job_queue_check.rake
|
150
|
-
- lib/dekiru/tasks/delayed_job_queue_monitor.rake
|
151
118
|
- lib/dekiru/tasks/smtp_check.rake
|
152
119
|
- lib/dekiru/version.rb
|
153
|
-
- lib/generators/dekiru/dekiru_generator.rb
|
154
120
|
- spec/dekiru/helper_spec.rb
|
155
121
|
- spec/spec_helper.rb
|
156
122
|
homepage: ''
|
@@ -172,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
138
|
version: '0'
|
173
139
|
requirements: []
|
174
140
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.6.12
|
176
142
|
signing_key:
|
177
143
|
specification_version: 4
|
178
144
|
summary: Usefull helper methods for Ruby on Rails
|
data/lib/dekiru/configure.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module Dekiru
|
2
|
-
def self.configure(&block)
|
3
|
-
@configure ||= Configure.new
|
4
|
-
yield @configure if block_given?
|
5
|
-
@configure
|
6
|
-
end
|
7
|
-
|
8
|
-
class Configure
|
9
|
-
attr_accessor :monitor_email, :monitor_api_key, :error_handle
|
10
|
-
def initialize
|
11
|
-
@error_handle = -> (e) {}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
require 'faraday_middleware'
|
3
|
-
|
4
|
-
module Dekiru
|
5
|
-
class JobMonClient
|
6
|
-
def host
|
7
|
-
'https://job-mon.herokuapp.com'
|
8
|
-
end
|
9
|
-
|
10
|
-
def conn
|
11
|
-
@conn ||= Faraday.new(:url => host) do |faraday|
|
12
|
-
faraday.request :url_encoded
|
13
|
-
faraday.request :json
|
14
|
-
faraday.response :json
|
15
|
-
faraday.adapter Faraday.default_adapter
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def api_key
|
20
|
-
Dekiru.configure.monitor_api_key
|
21
|
-
end
|
22
|
-
|
23
|
-
def job_start(task, estimate_time, monitor_email)
|
24
|
-
body = {
|
25
|
-
job: {
|
26
|
-
name: task.name,
|
27
|
-
end_time: Time.current.since(estimate_time),
|
28
|
-
email: monitor_email
|
29
|
-
}
|
30
|
-
}
|
31
|
-
response = conn.post "/api/apps/#{api_key}/jobs.json", body
|
32
|
-
response.body['id']
|
33
|
-
rescue => e
|
34
|
-
Dekiru.configure.error_handle.call(e)
|
35
|
-
nil
|
36
|
-
end
|
37
|
-
|
38
|
-
def job_end(job_id)
|
39
|
-
if job_id
|
40
|
-
conn.put "/api/apps/#{api_key}/jobs/#{job_id}/finished.json"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def send_queue_log(count)
|
45
|
-
body = {
|
46
|
-
queue_log: {
|
47
|
-
count: count,
|
48
|
-
rails_env: Rails.env,
|
49
|
-
}
|
50
|
-
}
|
51
|
-
response = conn.post "/api/apps/#{api_key}/queue_logs.json", body
|
52
|
-
response.body['id']
|
53
|
-
rescue => e
|
54
|
-
Dekiru.configure.error_handle.call(e)
|
55
|
-
nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/lib/dekiru/rake_monitor.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'dekiru/job_mon_client'
|
2
|
-
|
3
|
-
module Dekiru
|
4
|
-
module RakeMonitor
|
5
|
-
def resolve_args(args)
|
6
|
-
estimate_time = args.first.delete(:estimate_time)
|
7
|
-
[args, estimate_time]
|
8
|
-
end
|
9
|
-
|
10
|
-
def client
|
11
|
-
@client ||= JobMonClient.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def monitor_email
|
15
|
-
Dekiru.configure.monitor_email
|
16
|
-
end
|
17
|
-
|
18
|
-
def task_with_monitor(*args, &block)
|
19
|
-
args, estimate_time = resolve_args(args)
|
20
|
-
task *args do |t|
|
21
|
-
job_id = client.job_start(t, estimate_time, monitor_email)
|
22
|
-
block.call
|
23
|
-
client.job_end(job_id)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
self.extend Dekiru::RakeMonitor
|
@@ -1,18 +0,0 @@
|
|
1
|
-
namespace :dekiru do
|
2
|
-
desc '[Deprecated] Ops check for Delayed::Job queue'
|
3
|
-
task delayed_job_queue_check: :environment do
|
4
|
-
Rails.logger.info "[INFO] Start dekiru:delayed_job_queue_check env:#{Rails.env}"
|
5
|
-
Rails.logger.warn '[WARNING] Use dekiru:delayed_job_queue_monitor'
|
6
|
-
if defined?(Delayed::Job)
|
7
|
-
if (count = Delayed::Job.where('run_at < ? or last_error IS NOT NULL', 30.seconds.since).count) > 0
|
8
|
-
message = "There are #{count} jobs that are not running for Delayed::Job. Check job list!"
|
9
|
-
if defined?(Bugsnag)
|
10
|
-
Bugsnag.notify(message)
|
11
|
-
else
|
12
|
-
fail(message)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
Rails.logger.info "[INFO] End dekiru:delayed_job_queue_check env:#{Rails.env}"
|
17
|
-
end
|
18
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'dekiru/job_mon_client'
|
2
|
-
|
3
|
-
namespace :dekiru do
|
4
|
-
desc 'Ops monitor for Delayed::Job queue for job-mon'
|
5
|
-
task delayed_job_queue_monitor: :environment do
|
6
|
-
Rails.logger.info "[INFO] Start dekiru:delayed_job_queue_monitor env:#{Rails.env}"
|
7
|
-
if defined?(Delayed::Job)
|
8
|
-
count = Delayed::Job.where('run_at < ? or last_error IS NOT NULL', 30.seconds.since).count
|
9
|
-
Dekiru::JobMonClient.new.send_queue_log(count)
|
10
|
-
end
|
11
|
-
Rails.logger.info "[INFO] End dekiru:delayed_job_queue_monitor env:#{Rails.env}"
|
12
|
-
end
|
13
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
require 'dekiru/job_mon_client'
|
3
|
-
|
4
|
-
class DekiruGenerator < Rails::Generators::Base
|
5
|
-
source_root File.expand_path('../templates', __FILE__)
|
6
|
-
|
7
|
-
desc 'Configures the dekiru job monitor'
|
8
|
-
def create_initializer_file
|
9
|
-
initializer 'dekiru.rb' do
|
10
|
-
<<-EOF
|
11
|
-
Dekiru.configure do |config|
|
12
|
-
config.monitor_email = "support+#{fetch_app_name}@sonicgarden.jp"
|
13
|
-
config.monitor_api_key = "#{fetch_api_key}"
|
14
|
-
config.error_handle = -> (e) { Bugsnag.notify(e) }
|
15
|
-
end
|
16
|
-
EOF
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def client
|
21
|
-
@client ||= Dekiru::JobMonClient.new
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def fetch_api_key
|
27
|
-
res = client.conn.post '/api/apps.json', app: { name: fetch_app_name }
|
28
|
-
res.body['api_key']
|
29
|
-
end
|
30
|
-
|
31
|
-
def fetch_app_name
|
32
|
-
File.basename(Rails.root)
|
33
|
-
end
|
34
|
-
end
|