kurchatov 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d32e4c6e47ad7cd5c109519c4c6bcaf72617be4
4
- data.tar.gz: 8f2184acdc5c63422dc7aeb09403715f37254d13
3
+ metadata.gz: 752d3c7c9f2993350889451956a8705c50999bd8
4
+ data.tar.gz: 98ba3a8b8027decc9f88679732ca61fcc5a6c2c2
5
5
  SHA512:
6
- metadata.gz: c1f347fff73715f15d5327249099bd09e793a177d357d801c535caa3bbcff65a5c0371b7e82505b2ec6556181cbc22e7e98e3c001045b76331a8f144ddf6e33f
7
- data.tar.gz: 6b46ec7ee3a15d023d941a0e16bfb6bf6ccb468def4573de66cea400c33e803169ee568874d6f1f0568625fe826185c9539012e623575127c84c18d6208ad33a
6
+ metadata.gz: 56ad4cb255578bda435c63a008b44a1b15d520c79aa29f1c02a2daabe286331bf019b5e0b411e30d1e6c4af57df6166863d05b217e44518676a217e48e1d2817
7
+ data.tar.gz: 8af9c9a40b6cd0682ed1efdbf98cfaa194fa348c66dbe76de3c42f7acccf3aba0d17261fdf36a8d620674c6c6b9b3573d9c982cb9c9fd255f26a5f387a346ab2
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ rdoc
17
17
  spec/reports
18
18
  tmp
19
19
  dpkg
20
+ tests/tank*.rb
@@ -124,7 +124,9 @@ module Kurchatov
124
124
 
125
125
  def configure_test_plugin
126
126
  return unless Config[:test_plugin]
127
- monitor << Kurchatov::Plugins::DSL.load_riemann_plugin(Config[:test_plugin])
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
@@ -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 { |t| exit Config[:ERROR_PLUGIN_REQ] if t.died? && @stop_on_error }
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
@@ -33,7 +33,7 @@ module Kurchatov
33
33
  plugin
34
34
  end
35
35
 
36
- def start
36
+ def start!
37
37
  super
38
38
  run.nil? ? start_collect : start_run
39
39
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Kurchatov
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-13 00:00:00.000000000 Z
11
+ date: 2014-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: beefcake