god 0.13.2 → 0.13.3
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.
- data/Gemfile +1 -1
- data/History.txt +6 -0
- data/README.md +1 -1
- data/doc/god.asciidoc +32 -0
- data/god.gemspec +9 -6
- data/lib/god.rb +12 -4
- data/lib/god/conditions/process_running.rb +1 -0
- data/lib/god/conditions/socket_responding.rb +15 -5
- data/lib/god/contacts/airbrake.rb +44 -0
- data/lib/god/event_handler.rb +5 -1
- data/test/helper.rb +31 -9
- data/test/test_airbrake.rb +14 -0
- data/test/test_condition.rb +2 -0
- data/test/test_conditions_socket_responding.rb +55 -1
- data/test/test_event_handler.rb +8 -6
- data/test/test_god.rb +60 -0
- data/test/test_metric.rb +10 -8
- data/test/test_process.rb +12 -6
- metadata +64 -26
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
gemspec
|
data/History.txt
CHANGED
data/README.md
CHANGED
data/doc/god.asciidoc
CHANGED
@@ -642,6 +642,19 @@ $ sudo god stop mongrels
|
|
642
642
|
/////////////////////////////////////////////////////////////////////////////
|
643
643
|
/////////////////////////////////////////////////////////////////////////////
|
644
644
|
|
645
|
+
Invoke Commands for all watches
|
646
|
+
-------------------------------
|
647
|
+
|
648
|
+
If you need to invoke a command (e.g. Stop / Start / Restart) on all watches
|
649
|
+
you can simply omit the second parameter. For example, to start all watches:
|
650
|
+
|
651
|
+
```terminal
|
652
|
+
$ sudo god start
|
653
|
+
```
|
654
|
+
|
655
|
+
/////////////////////////////////////////////////////////////////////////////
|
656
|
+
/////////////////////////////////////////////////////////////////////////////
|
657
|
+
|
645
658
|
Redirecting STDOUT and STDERR of your Process
|
646
659
|
---------------------------------------------
|
647
660
|
|
@@ -1188,6 +1201,25 @@ format - The Symbol format [ :form | :json ] (default: :form).
|
|
1188
1201
|
|
1189
1202
|
```
|
1190
1203
|
|
1204
|
+
Airbrake
|
1205
|
+
~~~~~~~
|
1206
|
+
|
1207
|
+
Send a notice to airbrake (http://airbrake.io/).
|
1208
|
+
|
1209
|
+
```ruby
|
1210
|
+
God::Contacts::Airbrake.defaults do |d|
|
1211
|
+
...
|
1212
|
+
end
|
1213
|
+
|
1214
|
+
God.contact(:airbrake) do |c|
|
1215
|
+
...
|
1216
|
+
end
|
1217
|
+
```
|
1218
|
+
|
1219
|
+
```
|
1220
|
+
apikey - The String API key.
|
1221
|
+
```
|
1222
|
+
|
1191
1223
|
/////////////////////////////////////////////////////////////////////////////
|
1192
1224
|
/////////////////////////////////////////////////////////////////////////////
|
1193
1225
|
|
data/god.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'god'
|
6
|
-
s.version = '0.13.
|
7
|
-
s.date = '2013-
|
6
|
+
s.version = '0.13.3'
|
7
|
+
s.date = '2013-09-25'
|
8
8
|
|
9
9
|
s.summary = "Process monitoring framework."
|
10
10
|
s.description = "An easy to configure, easy to extend monitoring framework written in Ruby."
|
@@ -24,18 +24,19 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.extra_rdoc_files = %w[README.md]
|
25
25
|
|
26
26
|
s.add_development_dependency('json', '~> 1.6')
|
27
|
-
s.add_development_dependency('rake'
|
27
|
+
s.add_development_dependency('rake')
|
28
28
|
s.add_development_dependency('rdoc', '~> 3.10')
|
29
|
-
s.add_development_dependency('twitter', '~>
|
29
|
+
s.add_development_dependency('twitter', '~> 4.0')
|
30
30
|
s.add_development_dependency('prowly', '~> 0.3')
|
31
31
|
s.add_development_dependency('xmpp4r', '~> 0.5')
|
32
32
|
s.add_development_dependency('dike', '~> 0.0.3')
|
33
|
-
s.add_development_dependency('snapshot', '~> 1.0')
|
34
33
|
s.add_development_dependency('rcov', '~> 0.9')
|
35
34
|
s.add_development_dependency('daemons', '~> 1.1')
|
36
35
|
s.add_development_dependency('mocha', '~> 0.10')
|
37
36
|
s.add_development_dependency('gollum', '~> 1.3.1')
|
38
|
-
|
37
|
+
s.add_development_dependency('airbrake', '~> 3.1.7')
|
38
|
+
s.add_development_dependency('nokogiri', '~> 1.5.0')
|
39
|
+
s.add_development_dependency('activesupport', [ '>= 2.3.10', '< 4.0.0' ])
|
39
40
|
# = MANIFEST =
|
40
41
|
s.files = %w[
|
41
42
|
Announce.txt
|
@@ -79,6 +80,7 @@ Gem::Specification.new do |s|
|
|
79
80
|
lib/god/conditions/tries.rb
|
80
81
|
lib/god/configurable.rb
|
81
82
|
lib/god/contact.rb
|
83
|
+
lib/god/contacts/airbrake.rb
|
82
84
|
lib/god/contacts/campfire.rb
|
83
85
|
lib/god/contacts/email.rb
|
84
86
|
lib/god/contacts/jabber.rb
|
@@ -137,6 +139,7 @@ Gem::Specification.new do |s|
|
|
137
139
|
test/configs/test.rb
|
138
140
|
test/helper.rb
|
139
141
|
test/suite.rb
|
142
|
+
test/test_airbrake.rb
|
140
143
|
test/test_behavior.rb
|
141
144
|
test/test_campfire.rb
|
142
145
|
test/test_condition.rb
|
data/lib/god.rb
CHANGED
@@ -91,6 +91,7 @@ load_contact(:prowl)
|
|
91
91
|
load_contact(:scout)
|
92
92
|
load_contact(:twitter)
|
93
93
|
load_contact(:webhook)
|
94
|
+
load_contact(:airbrake)
|
94
95
|
|
95
96
|
$:.unshift File.join(File.dirname(__FILE__), *%w[.. ext god])
|
96
97
|
|
@@ -156,7 +157,7 @@ end
|
|
156
157
|
|
157
158
|
module God
|
158
159
|
# The String version number for this package.
|
159
|
-
VERSION = '0.13.
|
160
|
+
VERSION = '0.13.3'
|
160
161
|
|
161
162
|
# The Integer number of lines of backlog to keep for the logger.
|
162
163
|
LOG_BUFFER_SIZE_DEFAULT = 100
|
@@ -437,16 +438,23 @@ module God
|
|
437
438
|
end
|
438
439
|
end
|
439
440
|
|
441
|
+
def self.watches_by_name(name)
|
442
|
+
case name
|
443
|
+
when "", nil then self.watches.values.dup
|
444
|
+
else Array(self.watches[name] || self.groups[name]).dup
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
440
448
|
# Control the lifecycle of the given task(s).
|
441
449
|
#
|
442
|
-
# name - The String name of a task/group.
|
450
|
+
# name - The String name of a task/group. If empty, invokes command for all tasks.
|
443
451
|
# command - The String command to run. Valid commands are:
|
444
452
|
# "start", "monitor", "restart", "stop", "unmonitor", "remove".
|
445
453
|
#
|
446
454
|
# Returns an Array of String task names affected by the command.
|
447
455
|
def self.control(name, command)
|
448
456
|
# Get the list of items.
|
449
|
-
items =
|
457
|
+
items = self.watches_by_name(name)
|
450
458
|
|
451
459
|
jobs = []
|
452
460
|
|
@@ -527,7 +535,7 @@ module God
|
|
527
535
|
#
|
528
536
|
# Returns an Array of String names of the tasks affected.
|
529
537
|
def self.signal(name, signal)
|
530
|
-
items =
|
538
|
+
items = watches_by_name(name)
|
531
539
|
jobs = []
|
532
540
|
items.each { |w| jobs << Thread.new { w.signal(signal) } }
|
533
541
|
jobs.each { |j| j.join }
|
@@ -15,6 +15,10 @@ module God
|
|
15
15
|
# +port+ is the port (required if +family+ is 'tcp')
|
16
16
|
# +path+ is the path (required if +family+ is 'unix')
|
17
17
|
#
|
18
|
+
# Optional
|
19
|
+
# +responding+ is the boolean specifying whether you want to trigger if the socket is responding (true)
|
20
|
+
# or if it is not responding (false) (default false)
|
21
|
+
#
|
18
22
|
# Examples
|
19
23
|
#
|
20
24
|
# Trigger if the TCP socket on port 80 is not responding or the connection is refused
|
@@ -30,6 +34,13 @@ module God
|
|
30
34
|
# c.socket = 'tcp:80'
|
31
35
|
# end
|
32
36
|
#
|
37
|
+
# Trigger if the socket is responding
|
38
|
+
#
|
39
|
+
# on.condition(:socket_responding) do |c|
|
40
|
+
# c.socket = 'tcp:80'
|
41
|
+
# c.responding = true
|
42
|
+
# end
|
43
|
+
#
|
33
44
|
# Trigger if the socket is not responding or the connection is refused 5 times in a row
|
34
45
|
#
|
35
46
|
# on.condition(:socket_responding) do |c|
|
@@ -44,10 +55,8 @@ module God
|
|
44
55
|
# c.port = '/tmp/sock'
|
45
56
|
# end
|
46
57
|
#
|
47
|
-
|
48
|
-
|
49
58
|
class SocketResponding < PollCondition
|
50
|
-
attr_accessor :family, :addr, :port, :path, :times
|
59
|
+
attr_accessor :family, :addr, :port, :path, :times, :responding
|
51
60
|
|
52
61
|
def initialize
|
53
62
|
super
|
@@ -57,6 +66,7 @@ module God
|
|
57
66
|
# Set these to nil/0 values
|
58
67
|
self.port = 0
|
59
68
|
self.path = nil
|
69
|
+
self.responding = false
|
60
70
|
|
61
71
|
self.times = [1, 1]
|
62
72
|
end
|
@@ -108,13 +118,13 @@ module God
|
|
108
118
|
s = TCPSocket.new(self.addr, self.port)
|
109
119
|
rescue SystemCallError
|
110
120
|
end
|
111
|
-
status = s.nil?
|
121
|
+
status = self.responding == !s.nil?
|
112
122
|
elsif self.family == 'unix'
|
113
123
|
begin
|
114
124
|
s = UNIXSocket.new(self.path)
|
115
125
|
rescue SystemCallError
|
116
126
|
end
|
117
|
-
status = s.nil?
|
127
|
+
status = self.responding == !s.nil?
|
118
128
|
else
|
119
129
|
status = false
|
120
130
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Send a notice to Airbrake (http://airbrake.io/).
|
2
|
+
#
|
3
|
+
# apikey - The String API key.
|
4
|
+
|
5
|
+
CONTACT_DEPS[:airbrake] = ['airbrake']
|
6
|
+
CONTACT_DEPS[:airbrake].each do |d|
|
7
|
+
require d
|
8
|
+
end
|
9
|
+
|
10
|
+
module God
|
11
|
+
module Contacts
|
12
|
+
class Airbrake < Contact
|
13
|
+
|
14
|
+
class << self
|
15
|
+
attr_accessor :apikey
|
16
|
+
end
|
17
|
+
|
18
|
+
def valid?
|
19
|
+
valid = true
|
20
|
+
valid &= complain("Attribute 'apikey' must be specified", self) if self.apikey.nil?
|
21
|
+
valid
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_accessor :apikey
|
25
|
+
|
26
|
+
def notify(message, time, priority, category, host)
|
27
|
+
::Airbrake.configure {}
|
28
|
+
|
29
|
+
message = "God: #{message.to_s} at #{host}"
|
30
|
+
message << " | #{[category, priority].join(" ")}" unless category.to_s.empty? or priority.to_s.empty?
|
31
|
+
|
32
|
+
if ::Airbrake.notify nil, :error_message => message, :api_key => arg(:apikey)
|
33
|
+
self.info = "sent airbrake notification to #{self.name}"
|
34
|
+
else
|
35
|
+
self.info = "failed to send airbrake notification to #{self.name}"
|
36
|
+
end
|
37
|
+
rescue Object => e
|
38
|
+
applog(nil, :info, "failed to send airbrake notification: #{e.message}")
|
39
|
+
applog(nil, :debug, e.backtrace.join("\n"))
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/god/event_handler.rb
CHANGED
@@ -56,7 +56,7 @@ module God
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.start
|
59
|
-
Thread.new do
|
59
|
+
@@thread = Thread.new do
|
60
60
|
loop do
|
61
61
|
begin
|
62
62
|
@@handler.handle_events
|
@@ -72,6 +72,10 @@ module God
|
|
72
72
|
@@loaded = self.operational?
|
73
73
|
end
|
74
74
|
|
75
|
+
def self.stop
|
76
|
+
@@thread.kill if @@thread
|
77
|
+
end
|
78
|
+
|
75
79
|
def self.operational?
|
76
80
|
com = [false]
|
77
81
|
|
data/test/helper.rb
CHANGED
@@ -25,7 +25,7 @@ EOF
|
|
25
25
|
end
|
26
26
|
|
27
27
|
begin
|
28
|
-
require 'mocha'
|
28
|
+
require 'mocha/setup'
|
29
29
|
rescue LoadError
|
30
30
|
unless gems ||= false
|
31
31
|
require 'rubygems'
|
@@ -96,17 +96,25 @@ ensure
|
|
96
96
|
$VERBOSE = old_verbose
|
97
97
|
end
|
98
98
|
|
99
|
-
LOG.instance_variable_set(:@io, StringIO.new(
|
99
|
+
LOG.instance_variable_set(:@io, StringIO.new())
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
101
|
+
def output_logs
|
102
|
+
io = LOG.instance_variable_get(:@io)
|
103
|
+
LOG.instance_variable_set(:@io, $stderr)
|
104
|
+
yield
|
105
|
+
ensure
|
106
|
+
LOG.instance_variable_set(:@io, io)
|
108
107
|
end
|
109
108
|
|
109
|
+
# module Kernel
|
110
|
+
# def abort(text)
|
111
|
+
# raise SystemExit, text
|
112
|
+
# end
|
113
|
+
# def exit(code)
|
114
|
+
# raise SystemExit, "Exit code: #{code}"
|
115
|
+
# end
|
116
|
+
# end
|
117
|
+
|
110
118
|
module Test::Unit::Assertions
|
111
119
|
def assert_abort
|
112
120
|
assert_raise SystemExit do
|
@@ -143,3 +151,17 @@ class Object
|
|
143
151
|
Bypass.new(self)
|
144
152
|
end
|
145
153
|
end
|
154
|
+
|
155
|
+
# Make sure we return valid exit codes
|
156
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION >= "1.9"
|
157
|
+
module Kernel
|
158
|
+
alias :__at_exit :at_exit
|
159
|
+
def at_exit(&block)
|
160
|
+
__at_exit do
|
161
|
+
exit_status = $!.status if $!.is_a?(SystemExit)
|
162
|
+
block.call
|
163
|
+
exit exit_status if exit_status
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/helper'
|
3
|
+
|
4
|
+
class TestAirbrake < Test::Unit::TestCase
|
5
|
+
def test_notify
|
6
|
+
airbrake = God::Contacts::Airbrake.new
|
7
|
+
airbrake.apikey = "put_your_apikey_here"
|
8
|
+
airbrake.name = "Airbrake"
|
9
|
+
|
10
|
+
Airbrake.expects(:notify).returns "123"
|
11
|
+
|
12
|
+
airbrake.notify("Test message for airbrake", Time.now, "airbrake priority", "airbrake category", "")
|
13
|
+
end
|
14
|
+
end
|
data/test/test_condition.rb
CHANGED
@@ -58,6 +58,7 @@ class TestConditionsSocketResponding < Test::Unit::TestCase
|
|
58
58
|
assert_equal c.family, 'tcp'
|
59
59
|
assert_equal c.addr, '127.0.0.1'
|
60
60
|
assert_equal c.port, 443
|
61
|
+
assert_equal c.responding, false
|
61
62
|
# path should not be set for tcp sockets
|
62
63
|
assert_equal c.path, nil
|
63
64
|
end
|
@@ -67,11 +68,12 @@ class TestConditionsSocketResponding < Test::Unit::TestCase
|
|
67
68
|
c.socket = 'unix:/tmp/process.sock'
|
68
69
|
assert_equal c.family, 'unix'
|
69
70
|
assert_equal c.path, '/tmp/process.sock'
|
71
|
+
assert_equal c.responding, false
|
70
72
|
# path should not be set for unix domain sockets
|
71
73
|
assert_equal c.port, 0
|
72
74
|
end
|
73
75
|
|
74
|
-
# test
|
76
|
+
# test : responding = false
|
75
77
|
|
76
78
|
def test_test_tcp_should_return_false_if_socket_is_listening
|
77
79
|
c = Conditions::SocketResponding.new
|
@@ -119,4 +121,56 @@ class TestConditionsSocketResponding < Test::Unit::TestCase
|
|
119
121
|
assert_equal false, c.test
|
120
122
|
assert_equal true, c.test
|
121
123
|
end
|
124
|
+
|
125
|
+
# test : responding = true
|
126
|
+
|
127
|
+
def test_test_tcp_should_return_true_if_socket_is_listening_with_responding_true
|
128
|
+
c = Conditions::SocketResponding.new
|
129
|
+
c.responding = true
|
130
|
+
c.prepare
|
131
|
+
|
132
|
+
TCPSocket.expects(:new).returns(0)
|
133
|
+
assert_equal true, c.test
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_test_tcp_should_return_false_if_no_socket_is_listening_with_responding_true
|
137
|
+
c = Conditions::SocketResponding.new
|
138
|
+
c.responding = true
|
139
|
+
c.prepare
|
140
|
+
|
141
|
+
TCPSocket.expects(:new).returns(nil)
|
142
|
+
assert_equal false, c.test
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_test_unix_should_return_true_if_socket_is_listening_with_responding_true
|
146
|
+
c = Conditions::SocketResponding.new
|
147
|
+
c.responding = true
|
148
|
+
c.socket = 'unix:/some/path'
|
149
|
+
|
150
|
+
c.prepare
|
151
|
+
UNIXSocket.expects(:new).returns(0)
|
152
|
+
assert_equal true, c.test
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_test_unix_should_return_false_if_no_socket_is_listening_with_responding_true
|
156
|
+
c = Conditions::SocketResponding.new
|
157
|
+
c.socket = 'unix:/some/path'
|
158
|
+
c.responding = true
|
159
|
+
c.prepare
|
160
|
+
|
161
|
+
UNIXSocket.expects(:new).returns(nil)
|
162
|
+
assert_equal false, c.test
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_test_unix_should_return_false_if_socket_is_listening_2_times_with_responding_true
|
166
|
+
c = Conditions::SocketResponding.new
|
167
|
+
c.socket = 'unix:/some/path'
|
168
|
+
c.responding = true
|
169
|
+
c.times = [2, 2]
|
170
|
+
c.prepare
|
171
|
+
|
172
|
+
UNIXSocket.expects(:new).returns(nil).times(2)
|
173
|
+
assert_equal false, c.test
|
174
|
+
assert_equal false, c.test
|
175
|
+
end
|
122
176
|
end
|
data/test/test_event_handler.rb
CHANGED
@@ -72,9 +72,11 @@ class TestEventHandler < Test::Unit::TestCase
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
# This doesn't currently work:
|
76
|
+
#
|
77
|
+
# class TestEventHandlerOperational < Test::Unit::TestCase
|
78
|
+
# def test_operational
|
79
|
+
# God::EventHandler.start
|
80
|
+
# assert God::EventHandler.loaded?
|
81
|
+
# end
|
82
|
+
# end
|
data/test/test_god.rb
CHANGED
@@ -331,12 +331,72 @@ class TestGod < Test::Unit::TestCase
|
|
331
331
|
w.group = 'bar'
|
332
332
|
end
|
333
333
|
|
334
|
+
God.watch do |w|
|
335
|
+
w.name = 'bar1'
|
336
|
+
w.start = 'go'
|
337
|
+
w.group = 'foo'
|
338
|
+
end
|
339
|
+
|
334
340
|
God.watches['foo1'].expects(:monitor)
|
335
341
|
God.watches['foo2'].expects(:monitor)
|
342
|
+
God.watches['bar1'].expects(:monitor).never
|
336
343
|
|
337
344
|
God.control('bar', 'start')
|
338
345
|
end
|
339
346
|
|
347
|
+
def test_control_should_operate_on_all_watches_on_nil
|
348
|
+
God.watch do |w|
|
349
|
+
w.name = 'foo1'
|
350
|
+
w.start = 'go'
|
351
|
+
w.group = 'foo'
|
352
|
+
end
|
353
|
+
|
354
|
+
God.watch do |w|
|
355
|
+
w.name = 'foo2'
|
356
|
+
w.start = 'go'
|
357
|
+
w.group = 'foo'
|
358
|
+
end
|
359
|
+
|
360
|
+
God.watch do |w|
|
361
|
+
w.name = 'bar1'
|
362
|
+
w.start = 'go'
|
363
|
+
w.group = 'bar'
|
364
|
+
end
|
365
|
+
|
366
|
+
God.watches['foo1'].expects(:monitor)
|
367
|
+
God.watches['foo2'].expects(:monitor)
|
368
|
+
God.watches['bar1'].expects(:monitor)
|
369
|
+
|
370
|
+
God.control(nil, 'start')
|
371
|
+
end
|
372
|
+
|
373
|
+
def test_control_should_operate_on_all_watches_on_empty_string
|
374
|
+
God.watch do |w|
|
375
|
+
w.name = 'foo1'
|
376
|
+
w.start = 'go'
|
377
|
+
w.group = 'foo'
|
378
|
+
end
|
379
|
+
|
380
|
+
God.watch do |w|
|
381
|
+
w.name = 'foo2'
|
382
|
+
w.start = 'go'
|
383
|
+
w.group = 'foo'
|
384
|
+
end
|
385
|
+
|
386
|
+
God.watch do |w|
|
387
|
+
w.name = 'bar1'
|
388
|
+
w.start = 'go'
|
389
|
+
w.group = 'bar'
|
390
|
+
end
|
391
|
+
|
392
|
+
God.watches['foo1'].expects(:monitor)
|
393
|
+
God.watches['foo2'].expects(:monitor)
|
394
|
+
God.watches['bar1'].expects(:monitor)
|
395
|
+
|
396
|
+
God.control('', 'start')
|
397
|
+
end
|
398
|
+
|
399
|
+
|
340
400
|
# stop_all
|
341
401
|
|
342
402
|
# terminate
|
data/test/test_metric.rb
CHANGED
@@ -41,14 +41,16 @@ class TestMetric < Test::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
# This doesn't currently work:
|
45
|
+
#
|
46
|
+
# def test_condition_should_allow_generation_of_subclasses_of_poll_or_event
|
47
|
+
# metric = Metric.new(stub(:name => 'foo', :interval => 10), nil)
|
48
|
+
#
|
49
|
+
# assert_nothing_raised do
|
50
|
+
# metric.condition(:fake_poll_condition)
|
51
|
+
# metric.condition(:fake_event_condition)
|
52
|
+
# end
|
53
|
+
# end
|
52
54
|
|
53
55
|
def test_condition_should_abort_if_not_subclass_of_poll_or_event
|
54
56
|
metric = Metric.new(stub(:name => 'foo', :interval => 10), nil)
|
data/test/test_process.rb
CHANGED
@@ -59,7 +59,9 @@ class TestProcessChild < Test::Unit::TestCase
|
|
59
59
|
def test_valid_should_return_true_if_gid_exists
|
60
60
|
@p.start = 'qux'
|
61
61
|
@p.log = '/tmp/foo.log'
|
62
|
-
@p.gid =
|
62
|
+
@p.gid = Etc.getgrgid(::Process.gid).name
|
63
|
+
|
64
|
+
::Process.stubs(:groups=)
|
63
65
|
|
64
66
|
assert @p.valid?
|
65
67
|
end
|
@@ -104,12 +106,16 @@ class TestProcessChild < Test::Unit::TestCase
|
|
104
106
|
|
105
107
|
def test_valid_should_return_true_with_chroot_and_valid_log
|
106
108
|
@p.start = 'qux'
|
107
|
-
@p.chroot =
|
108
|
-
@p.log =
|
109
|
+
@p.chroot = Dir.pwd
|
110
|
+
@p.log = "#{@p.chroot}/foo.log"
|
111
|
+
|
112
|
+
File.expects(:exist?).with(@p.chroot).returns(true)
|
113
|
+
File.expects(:exist?).with(@p.log).returns(true)
|
114
|
+
File.expects(:exist?).with("#{@p.chroot}/dev/null").returns(true)
|
115
|
+
|
116
|
+
File.stubs(:writable?).with('/foo.log').returns(true)
|
109
117
|
|
110
|
-
|
111
|
-
File.expects(:exist?).with('/tmp/foo.log').returns(true)
|
112
|
-
File.expects(:exist?).with('/tmp/dev/null').returns(true)
|
118
|
+
::Dir.stubs(:chroot)
|
113
119
|
|
114
120
|
assert @p.valid?
|
115
121
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 13
|
8
|
-
-
|
9
|
-
version: 0.13.
|
8
|
+
- 3
|
9
|
+
version: 0.13.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Tom Preston-Werner
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-
|
19
|
+
date: 2013-09-25 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -36,12 +36,11 @@ dependencies:
|
|
36
36
|
type: :development
|
37
37
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
segments:
|
42
42
|
- 0
|
43
|
-
|
44
|
-
version: "0.9"
|
43
|
+
version: "0"
|
45
44
|
name: rake
|
46
45
|
requirement: *id002
|
47
46
|
prerelease: false
|
@@ -65,9 +64,9 @@ dependencies:
|
|
65
64
|
- - ~>
|
66
65
|
- !ruby/object:Gem::Version
|
67
66
|
segments:
|
68
|
-
-
|
67
|
+
- 4
|
69
68
|
- 0
|
70
|
-
version: "
|
69
|
+
version: "4.0"
|
71
70
|
name: twitter
|
72
71
|
requirement: *id004
|
73
72
|
prerelease: false
|
@@ -118,10 +117,10 @@ dependencies:
|
|
118
117
|
- - ~>
|
119
118
|
- !ruby/object:Gem::Version
|
120
119
|
segments:
|
121
|
-
- 1
|
122
120
|
- 0
|
123
|
-
|
124
|
-
|
121
|
+
- 9
|
122
|
+
version: "0.9"
|
123
|
+
name: rcov
|
125
124
|
requirement: *id008
|
126
125
|
prerelease: false
|
127
126
|
- !ruby/object:Gem::Dependency
|
@@ -131,10 +130,10 @@ dependencies:
|
|
131
130
|
- - ~>
|
132
131
|
- !ruby/object:Gem::Version
|
133
132
|
segments:
|
134
|
-
-
|
135
|
-
-
|
136
|
-
version: "
|
137
|
-
name:
|
133
|
+
- 1
|
134
|
+
- 1
|
135
|
+
version: "1.1"
|
136
|
+
name: daemons
|
138
137
|
requirement: *id009
|
139
138
|
prerelease: false
|
140
139
|
- !ruby/object:Gem::Dependency
|
@@ -144,10 +143,10 @@ dependencies:
|
|
144
143
|
- - ~>
|
145
144
|
- !ruby/object:Gem::Version
|
146
145
|
segments:
|
147
|
-
-
|
148
|
-
-
|
149
|
-
version: "
|
150
|
-
name:
|
146
|
+
- 0
|
147
|
+
- 10
|
148
|
+
version: "0.10"
|
149
|
+
name: mocha
|
151
150
|
requirement: *id010
|
152
151
|
prerelease: false
|
153
152
|
- !ruby/object:Gem::Dependency
|
@@ -157,10 +156,11 @@ dependencies:
|
|
157
156
|
- - ~>
|
158
157
|
- !ruby/object:Gem::Version
|
159
158
|
segments:
|
160
|
-
-
|
161
|
-
-
|
162
|
-
|
163
|
-
|
159
|
+
- 1
|
160
|
+
- 3
|
161
|
+
- 1
|
162
|
+
version: 1.3.1
|
163
|
+
name: gollum
|
164
164
|
requirement: *id011
|
165
165
|
prerelease: false
|
166
166
|
- !ruby/object:Gem::Dependency
|
@@ -170,13 +170,48 @@ dependencies:
|
|
170
170
|
- - ~>
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
segments:
|
173
|
-
- 1
|
174
173
|
- 3
|
175
174
|
- 1
|
176
|
-
|
177
|
-
|
175
|
+
- 7
|
176
|
+
version: 3.1.7
|
177
|
+
name: airbrake
|
178
178
|
requirement: *id012
|
179
179
|
prerelease: false
|
180
|
+
- !ruby/object:Gem::Dependency
|
181
|
+
type: :development
|
182
|
+
version_requirements: &id013 !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ~>
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
segments:
|
187
|
+
- 1
|
188
|
+
- 5
|
189
|
+
- 0
|
190
|
+
version: 1.5.0
|
191
|
+
name: nokogiri
|
192
|
+
requirement: *id013
|
193
|
+
prerelease: false
|
194
|
+
- !ruby/object:Gem::Dependency
|
195
|
+
type: :development
|
196
|
+
version_requirements: &id014 !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
segments:
|
201
|
+
- 2
|
202
|
+
- 3
|
203
|
+
- 10
|
204
|
+
version: 2.3.10
|
205
|
+
- - <
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
segments:
|
208
|
+
- 4
|
209
|
+
- 0
|
210
|
+
- 0
|
211
|
+
version: 4.0.0
|
212
|
+
name: activesupport
|
213
|
+
requirement: *id014
|
214
|
+
prerelease: false
|
180
215
|
description: An easy to configure, easy to extend monitoring framework written in Ruby.
|
181
216
|
email: god-rb@googlegroups.com
|
182
217
|
executables:
|
@@ -227,6 +262,7 @@ files:
|
|
227
262
|
- lib/god/conditions/tries.rb
|
228
263
|
- lib/god/configurable.rb
|
229
264
|
- lib/god/contact.rb
|
265
|
+
- lib/god/contacts/airbrake.rb
|
230
266
|
- lib/god/contacts/campfire.rb
|
231
267
|
- lib/god/contacts/email.rb
|
232
268
|
- lib/god/contacts/jabber.rb
|
@@ -285,6 +321,7 @@ files:
|
|
285
321
|
- test/configs/test.rb
|
286
322
|
- test/helper.rb
|
287
323
|
- test/suite.rb
|
324
|
+
- test/test_airbrake.rb
|
288
325
|
- test/test_behavior.rb
|
289
326
|
- test/test_campfire.rb
|
290
327
|
- test/test_condition.rb
|
@@ -346,6 +383,7 @@ signing_key:
|
|
346
383
|
specification_version: 2
|
347
384
|
summary: Process monitoring framework.
|
348
385
|
test_files:
|
386
|
+
- test/test_airbrake.rb
|
349
387
|
- test/test_behavior.rb
|
350
388
|
- test/test_campfire.rb
|
351
389
|
- test/test_condition.rb
|