kurchatov 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/kurchatov/application.rb +4 -2
- data/lib/kurchatov/monitor.rb +19 -3
- data/lib/kurchatov/plugin/config.rb +7 -0
- data/lib/kurchatov/plugin/riemann.rb +1 -1
- data/lib/kurchatov/plugin.rb +10 -2
- data/lib/kurchatov/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 752d3c7c9f2993350889451956a8705c50999bd8
|
4
|
+
data.tar.gz: 98ba3a8b8027decc9f88679732ca61fcc5a6c2c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56ad4cb255578bda435c63a008b44a1b15d520c79aa29f1c02a2daabe286331bf019b5e0b411e30d1e6c4af57df6166863d05b217e44518676a217e48e1d2817
|
7
|
+
data.tar.gz: 8af9c9a40b6cd0682ed1efdbf98cfaa194fa348c66dbe76de3c42f7acccf3aba0d17261fdf36a8d620674c6c6b9b3573d9c982cb9c9fd255f26a5f387a346ab2
|
data/.gitignore
CHANGED
@@ -124,7 +124,9 @@ module Kurchatov
|
|
124
124
|
|
125
125
|
def configure_test_plugin
|
126
126
|
return unless Config[:test_plugin]
|
127
|
-
|
127
|
+
plugins = Kurchatov::Plugins::Config.load_test_plugin(Config[:test_plugin],
|
128
|
+
Config[:config_file])
|
129
|
+
plugins.each {|p| monitor << p}
|
128
130
|
end
|
129
131
|
|
130
132
|
def run
|
@@ -134,7 +136,7 @@ module Kurchatov
|
|
134
136
|
load_plugins(File.join(File.dirname(__FILE__),'responders'))
|
135
137
|
load_plugins(Config[:plugin_paths])
|
136
138
|
configure_test_plugin
|
137
|
-
monitor.start
|
139
|
+
monitor.start!
|
138
140
|
end
|
139
141
|
|
140
142
|
end
|
data/lib/kurchatov/monitor.rb
CHANGED
@@ -8,7 +8,7 @@ module Kurchatov
|
|
8
8
|
|
9
9
|
def initialize(plugin)
|
10
10
|
@plugin = plugin
|
11
|
-
@thread = Thread.new { @plugin.start }
|
11
|
+
@thread = Thread.new { @plugin.start! }
|
12
12
|
@count_errors = 0
|
13
13
|
@last_error = nil
|
14
14
|
@last_error_at = nil
|
@@ -22,6 +22,14 @@ module Kurchatov
|
|
22
22
|
@plugin.plugin_config
|
23
23
|
end
|
24
24
|
|
25
|
+
def stop!
|
26
|
+
Thread.kill(@thread)
|
27
|
+
end
|
28
|
+
|
29
|
+
def stopped?
|
30
|
+
@plugin.stopped?
|
31
|
+
end
|
32
|
+
|
25
33
|
def died?
|
26
34
|
return false if @thread.alive?
|
27
35
|
# thread died, join and extract error
|
@@ -57,9 +65,17 @@ module Kurchatov
|
|
57
65
|
@tasks << Task.new(plugin)
|
58
66
|
end
|
59
67
|
|
60
|
-
def start
|
68
|
+
def start!
|
61
69
|
loop do
|
62
|
-
@tasks.each
|
70
|
+
@tasks.each do |task|
|
71
|
+
if task.died? && @stop_on_error
|
72
|
+
exit(Config[:ERROR_PLUGIN_REQ])
|
73
|
+
end
|
74
|
+
if task.stopped?
|
75
|
+
task.stop!
|
76
|
+
@tasks.delete(task)
|
77
|
+
end
|
78
|
+
end
|
63
79
|
Log.debug("Check alive plugins [#{@tasks.count}]")
|
64
80
|
sleep CHECK_ALIVE_TIMEOUT
|
65
81
|
end
|
@@ -6,6 +6,13 @@ module Kurchatov
|
|
6
6
|
module Plugins
|
7
7
|
module Config
|
8
8
|
|
9
|
+
def self.load_test_plugin(plugin_path, config_file)
|
10
|
+
config = File.exists?(config_file) ? YAML.load_file(config_file) : {}
|
11
|
+
plugin = Kurchatov::Plugins::DSL.load_riemann_plugin(plugin_path)
|
12
|
+
plugin.plugin.merge!(config[plugin.name]) unless config.empty?
|
13
|
+
[plugin]
|
14
|
+
end
|
15
|
+
|
9
16
|
def self.find_plugin(name, array)
|
10
17
|
array.find { |p| p.name == name }
|
11
18
|
end
|
data/lib/kurchatov/plugin.rb
CHANGED
@@ -7,12 +7,20 @@ module Kurchatov
|
|
7
7
|
@name = name
|
8
8
|
@ignore_errors = false
|
9
9
|
@always_start = false
|
10
|
+
@stopped = false
|
10
11
|
end
|
11
12
|
|
12
|
-
def start
|
13
|
-
|
13
|
+
def start!
|
14
|
+
return if @stopped
|
14
15
|
end
|
15
16
|
|
17
|
+
def stop!
|
18
|
+
@stopped = true
|
19
|
+
end
|
20
|
+
|
21
|
+
def stopped?
|
22
|
+
@stopped
|
23
|
+
end
|
16
24
|
|
17
25
|
end
|
18
26
|
end
|
data/lib/kurchatov/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kurchatov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasiliev Dmitry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: beefcake
|