From 1a81a1b38278c04aca1f710b739a7d30a03bbd56 Mon Sep 17 00:00:00 2001 From: Eric Lindvall Date: Tue, 1 May 2012 23:32:43 -0700 Subject: [PATCH 1/6] Provide a simple way to prevent bundler auto-loading Most cases of problems we see with conflicts with sugar.rb are due to bundler autoloading god into Rails processes when it really doesn't need to be. --- bin/god | 4 +++- lib/god.rb | 10 ++++++++-- test/helper.rb | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/god b/bin/god index f7362388..9219065a 100755 --- a/bin/god +++ b/bin/god @@ -4,7 +4,6 @@ STDOUT.sync = true $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib]) -require 'rubygems' require 'optparse' require 'drb' require 'yaml' @@ -105,6 +104,9 @@ begin abort("Invalid log level '#{options[:log_level]}'") end + # Use this flag to actually load all of the god infrastructure + $should_really_load_god = true + # dispatch if !options[:config] && options[:version] require 'god' diff --git a/lib/god.rb b/lib/god.rb index eb8318f4..2f76e42b 100644 --- a/lib/god.rb +++ b/lib/god.rb @@ -1,4 +1,8 @@ -$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed +# Bail out before loading anything unless this flag is set. +# +# We are doing this to guard against bundler autoloading because there is +# no value in loading god in most processes. +if $should_really_load_god # core require 'stringio' @@ -726,7 +730,7 @@ def self.at_exit # private # Match a shortened pattern against a list of String candidates. - # The pattern is expanded into a regular expression by + # The pattern is expanded into a regular expression by # inserting .* between each character. # # pattern - The String containing the abbreviation. @@ -756,3 +760,5 @@ def self.pattern_match(pattern, list) at_exit do God.at_exit if $run end + +end \ No newline at end of file diff --git a/test/helper.rb b/test/helper.rb index 063924bb..4d201100 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,4 +1,8 @@ -require 'rubygems' +$:.unshift File.expand_path('../../lib', __FILE__) # For use/testing when no gem is installed + +# Use this flag to actually load all of the god infrastructure +$should_really_load_god = true + require File.join(File.dirname(__FILE__), *%w[.. lib god sys_logger]) require File.join(File.dirname(__FILE__), *%w[.. lib god]) God::EventHandler.load From 64a0ec2b1a4e3c3be5405fd66d4a0d167d119148 Mon Sep 17 00:00:00 2001 From: Eric Lindvall Date: Wed, 9 May 2012 14:39:03 -0700 Subject: [PATCH 2/6] Shorten the name of the global to $load_god --- bin/god | 2 +- lib/god.rb | 2 +- test/helper.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/god b/bin/god index 9219065a..149df077 100755 --- a/bin/god +++ b/bin/god @@ -105,7 +105,7 @@ begin end # Use this flag to actually load all of the god infrastructure - $should_really_load_god = true + $load_god = true # dispatch if !options[:config] && options[:version] diff --git a/lib/god.rb b/lib/god.rb index 2f76e42b..931fd151 100644 --- a/lib/god.rb +++ b/lib/god.rb @@ -2,7 +2,7 @@ # # We are doing this to guard against bundler autoloading because there is # no value in loading god in most processes. -if $should_really_load_god +if $load_god # core require 'stringio' diff --git a/test/helper.rb b/test/helper.rb index 4d201100..09438ddb 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,7 +1,7 @@ $:.unshift File.expand_path('../../lib', __FILE__) # For use/testing when no gem is installed # Use this flag to actually load all of the god infrastructure -$should_really_load_god = true +$load_god = true require File.join(File.dirname(__FILE__), *%w[.. lib god sys_logger]) require File.join(File.dirname(__FILE__), *%w[.. lib god]) From 7a21825a86d39a56f3e238395074b3625cfb19fa Mon Sep 17 00:00:00 2001 From: "Scott J. Goldman" Date: Sun, 16 Sep 2012 21:57:55 -0700 Subject: [PATCH 3/6] Don't log if processes are running and within bounds These logs are creating quite a bit of log spew on the github.com servers, and I don't think they really provide much value? --- lib/god/conditions/cpu_usage.rb | 1 - lib/god/conditions/memory_usage.rb | 1 - lib/god/conditions/process_running.rb | 3 --- lib/god/conditions/socket_responding.rb | 1 - 4 files changed, 6 deletions(-) diff --git a/lib/god/conditions/cpu_usage.rb b/lib/god/conditions/cpu_usage.rb index 709a782e..77caefb6 100644 --- a/lib/god/conditions/cpu_usage.rb +++ b/lib/god/conditions/cpu_usage.rb @@ -70,7 +70,6 @@ def test self.info = "cpu out of bounds #{history}" return true else - self.info = "cpu within bounds #{history}" return false end end diff --git a/lib/god/conditions/memory_usage.rb b/lib/god/conditions/memory_usage.rb index 2ab133bd..90580188 100644 --- a/lib/god/conditions/memory_usage.rb +++ b/lib/god/conditions/memory_usage.rb @@ -72,7 +72,6 @@ def test self.info = "memory out of bounds #{history}" return true else - self.info = "memory within bounds #{history}" return false end end diff --git a/lib/god/conditions/process_running.rb b/lib/god/conditions/process_running.rb index 0e741dca..911b955f 100644 --- a/lib/god/conditions/process_running.rb +++ b/lib/god/conditions/process_running.rb @@ -46,7 +46,6 @@ def test active = pid && System::Process.new(pid).exists? if (self.running && active) - self.info.concat(["process is running"]) true elsif (!self.running && !active) self.info.concat(["process is not running"]) @@ -54,8 +53,6 @@ def test else if self.running self.info.concat(["process is not running"]) - else - self.info.concat(["process is running"]) end false end diff --git a/lib/god/conditions/socket_responding.rb b/lib/god/conditions/socket_responding.rb index 9bc47e82..d3083455 100644 --- a/lib/god/conditions/socket_responding.rb +++ b/lib/god/conditions/socket_responding.rb @@ -123,7 +123,6 @@ def test self.info = "socket out of bounds #{history}" return true else - self.info = "socket within bounds #{history}" return false end end From 22139d7ac345aeb05887a0f48e5ff475cccfd044 Mon Sep 17 00:00:00 2001 From: "Scott J. Goldman" Date: Sun, 16 Sep 2012 23:13:01 -0700 Subject: [PATCH 4/6] Default a bunch of conditions to have an empty array Empty arrays will let God::Task#handle_poll skip logging stuff in the INFO loglevel. --- lib/god/conditions/cpu_usage.rb | 1 + lib/god/conditions/disk_usage.rb | 2 +- lib/god/conditions/memory_usage.rb | 1 + lib/god/conditions/socket_responding.rb | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/god/conditions/cpu_usage.rb b/lib/god/conditions/cpu_usage.rb index 77caefb6..eddb17b0 100644 --- a/lib/god/conditions/cpu_usage.rb +++ b/lib/god/conditions/cpu_usage.rb @@ -63,6 +63,7 @@ def valid? def test process = System::Process.new(self.pid) @timeline.push(process.percent_cpu) + self.info = [] history = "[" + @timeline.map { |x| "#{x > self.above ? '*' : ''}#{x}%%" }.join(", ") + "]" diff --git a/lib/god/conditions/disk_usage.rb b/lib/god/conditions/disk_usage.rb index ea91e7c9..ab9676d9 100644 --- a/lib/god/conditions/disk_usage.rb +++ b/lib/god/conditions/disk_usage.rb @@ -18,12 +18,12 @@ def valid? end def test + self.info = [] usage = `df -P | grep -i " #{self.mount_point}$" | awk '{print $5}' | sed 's/%//'` if usage.to_i > self.above self.info = "disk space out of bounds" return true else - self.info = "disk space ok" return false end end diff --git a/lib/god/conditions/memory_usage.rb b/lib/god/conditions/memory_usage.rb index 90580188..909ef59a 100644 --- a/lib/god/conditions/memory_usage.rb +++ b/lib/god/conditions/memory_usage.rb @@ -65,6 +65,7 @@ def valid? def test process = System::Process.new(self.pid) @timeline.push(process.memory) + self.info = [] history = "[" + @timeline.map { |x| "#{x > self.above ? '*' : ''}#{x}kb" }.join(", ") + "]" diff --git a/lib/god/conditions/socket_responding.rb b/lib/god/conditions/socket_responding.rb index d3083455..53ff8338 100644 --- a/lib/god/conditions/socket_responding.rb +++ b/lib/god/conditions/socket_responding.rb @@ -102,6 +102,7 @@ def valid? end def test + self.info = [] if self.family == 'tcp' begin s = TCPSocket.new(self.addr, self.port) From 8733f75a9d4e737e7286dd617f4a67272cb483d8 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Mon, 17 Sep 2012 11:29:23 -0700 Subject: [PATCH 5/6] Release 0.13.0 --- History.txt | 8 ++++++-- god.gemspec | 4 ++-- lib/god.rb | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/History.txt b/History.txt index fcb03184..861b2f4b 100644 --- a/History.txt +++ b/History.txt @@ -1,8 +1,12 @@ -== 0.12.1 +== 0.13.0 / 2012-09-17 + * Minor Changes + * Reduce verbosity of non-failing conditions (#111) + +== 0.12.1 / 2012-01-21 * Bug Fixes * Fix undefined variable problem in CLI (#82) -== 0.12.0 +== 0.12.0 / 2012-01-13 * Minor Enhancements * Add umask support * Add socket response condition (#25) diff --git a/god.gemspec b/god.gemspec index 52e70411..b03d07b9 100644 --- a/god.gemspec +++ b/god.gemspec @@ -3,8 +3,8 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.name = 'god' - s.version = '0.12.1' - s.date = '2012-01-21' + s.version = '0.13.0' + s.date = '2012-09-17' s.summary = "Process monitoring framework." s.description = "An easy to configure, easy to extend monitoring framework written in Ruby." diff --git a/lib/god.rb b/lib/god.rb index eb8318f4..9cc4632a 100644 --- a/lib/god.rb +++ b/lib/god.rb @@ -151,7 +151,7 @@ def safe_attr_accessor(*args) module God # The String version number for this package. - VERSION = '0.12.1' + VERSION = '0.13.0' # The Integer number of lines of backlog to keep for the logger. LOG_BUFFER_SIZE_DEFAULT = 100 From b0257b3939723dfb481e62c1fe9b079cc1f525b5 Mon Sep 17 00:00:00 2001 From: Eric Lindvall Date: Tue, 18 Sep 2012 12:32:56 -0700 Subject: [PATCH 6/6] Release 0.13.1 --- History.txt | 4 ++++ god.gemspec | 4 ++-- lib/god.rb | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/History.txt b/History.txt index 861b2f4b..0c9768a4 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,7 @@ +== 0.13.1 / 2012-09-18 + * Minor Changes + * Prevent auto-loading from bundler by requiring $load_god to require (#97) + == 0.13.0 / 2012-09-17 * Minor Changes * Reduce verbosity of non-failing conditions (#111) diff --git a/god.gemspec b/god.gemspec index b03d07b9..773c5c73 100644 --- a/god.gemspec +++ b/god.gemspec @@ -3,8 +3,8 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.name = 'god' - s.version = '0.13.0' - s.date = '2012-09-17' + s.version = '0.13.1' + s.date = '2012-09-18' s.summary = "Process monitoring framework." s.description = "An easy to configure, easy to extend monitoring framework written in Ruby." diff --git a/lib/god.rb b/lib/god.rb index c13567b2..cafac005 100644 --- a/lib/god.rb +++ b/lib/god.rb @@ -155,7 +155,7 @@ def safe_attr_accessor(*args) module God # The String version number for this package. - VERSION = '0.13.0' + VERSION = '0.13.1' # The Integer number of lines of backlog to keep for the logger. LOG_BUFFER_SIZE_DEFAULT = 100