Permalink
Browse files

Merge branch 'master' into proc_fs

Conflicts:

	lib/god/system/process.rb
  • Loading branch information...
kevinclark committed May 14, 2008
2 parents 466dbc3 + 582fca9 commit ba98fdce987aa50fe840a2cafd5f1f4e6e0815aa
View
@@ -2,3 +2,4 @@ coverage
pkg
*.log
logs
+*.rbc
View
@@ -1,3 +1,19 @@
+== 0.7.5 / 2008-02-21
+ * Bug Fixes
+ * Remove Ruby's Logger and replace with custom SimpleLogger to stop threaded leak
+
+== 0.7.4 / 2008-02-18
+ * Bug Fixes
+ * Introduce local scope to prevent faulty optimization that causes memory to leak
+
+== 0.7.3 / 2008-02-14
+ * Minor Enhancements
+ * Add --bleakhouse to make running diagnostics easier
+ * Bug Fixes
+ * Use ::Process.kill(0, ...) instead of `kill -0` [queso]
+ * Fix pid_file behavior in process-centric conditions so they work with tasks [matias]
+ * Redirect output of daemonized god to log file or /dev/null earlier [_eric]
+
== 0.7.2 / 2008-02-04
* Bug Fixes
* Start event system for CLI commands
View
@@ -45,6 +45,7 @@ lib/god/logger.rb
lib/god/metric.rb
lib/god/process.rb
lib/god/registry.rb
+lib/god/simple_logger.rb
lib/god/socket.rb
lib/god/sugar.rb
lib/god/system/process.rb
@@ -67,6 +68,7 @@ test/configs/daemon_polls/daemon_polls.god
test/configs/daemon_polls/simple_server.rb
test/configs/degrading_lambda/degrading_lambda.god
test/configs/degrading_lambda/tcp_server.rb
+test/configs/matias/matias.god
test/configs/real.rb
test/configs/running_load/running_load.god
test/configs/stress/simple_server.rb
View
@@ -24,12 +24,20 @@ Sign up for the god mailing list at http://groups.google.com/group/god-rb
== INSTALL:
$ sudo gem install god
+
+== CONTRIBUTE:
+
+Latest code is available at http://github.com/mojombo/god
+
+The 'master' branch can be cloned with:
+
+ $ git clone git://github.com/mojombo/god.git
== LICENSE:
(The MIT License)
-Copyright (c) 2007 FIX
+Copyright (c) 2007 Tom Preston-Werner
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
@@ -1,7 +1,7 @@
require 'rubygems'
require 'hoe'
-Hoe.new('god', '0.7.2') do |p|
+Hoe.new('god', '0.7.5') do |p|
p.rubyforge_name = 'god'
p.author = 'Tom Preston-Werner'
p.email = 'tom@rubyisawesome.com'
View
@@ -87,6 +87,10 @@ begin
opts.on("--no-events", "Disable the event system") do
options[:events] = false
end
+
+ opts.on("--bleakhouse", "Enable bleakhouse profiling") do
+ options[:bleakhouse] = true
+ end
end
opts.parse!
View
@@ -5,7 +5,6 @@
# core
require 'stringio'
-require 'logger'
require 'fileutils'
begin
@@ -19,6 +18,7 @@
# internal requires
require 'god/errors'
+require 'god/simple_logger'
require 'god/logger'
require 'god/system/process'
@@ -74,7 +74,6 @@
# App wide logging system
LOG = God::Logger.new
-LOG.datetime_format = "%Y-%m-%d %H:%M:%S "
def applog(watch, level, text)
LOG.log(watch, level, text)
@@ -134,7 +133,7 @@ def safe_attr_accessor(*args)
end
module God
- VERSION = '0.7.2'
+ VERSION = '0.7.5'
LOG_BUFFER_SIZE_DEFAULT = 100
PID_FILE_DIRECTORY_DEFAULTS = ['/var/run/god', '~/.god/pids']
View
@@ -33,6 +33,60 @@ def attach
end
end
+ def default_run
+ # start attached pid watcher if necessary
+ if @options[:attach]
+ self.attach
+ end
+
+ if @options[:port]
+ God.port = @options[:port]
+ end
+
+ if @options[:events]
+ God::EventHandler.load
+ end
+
+ # set log level, defaults to WARN
+ if @options[:log_level]
+ God.log_level = @options[:log_level]
+ else
+ God.log_level = @options[:daemonize] ? :warn : :info
+ end
+
+ if @options[:config]
+ unless File.exist?(@options[:config])
+ abort "File not found: #{@options[:config]}"
+ end
+
+ # start the event handler
+ God::EventHandler.start if God::EventHandler.loaded?
+
+ load_config @options[:config]
+ end
+ end
+
+ def run_in_front
+ require 'god'
+
+ if @options[:bleakhouse]
+ BleakHouseDiagnostic.install
+ end
+
+ default_run
+
+ if @options[:log]
+ log_file = File.expand_path(@options[:log])
+ puts "Sending output to log file: #{log_file}"
+
+ # reset file descriptors
+ STDIN.reopen "/dev/null"
+ STDOUT.reopen(log_file, "a")
+ STDERR.reopen STDOUT
+ STDOUT.sync = true
+ end
+ end
+
def run_daemonized
# trap and ignore SIGHUP
Signal.trap('HUP') {}
@@ -43,74 +97,34 @@ def run_daemonized
log_file = @options[:log] || "/dev/null"
- unless God::EventHandler.loaded?
- puts
- puts "***********************************************************************"
- puts "*"
- puts "* Event conditions are not available for your installation of god."
- puts "* You may still use and write custom conditions using the poll system"
- puts "*"
- puts "***********************************************************************"
- puts
- end
-
- # start attached pid watcher if necessary
- if @options[:attach]
- self.attach
- end
-
- # set port if requested
- if @options[:port]
- God.port = @options[:port]
- end
+ # reset file descriptors
+ STDIN.reopen "/dev/null"
+ STDOUT.reopen(log_file, "a")
+ STDERR.reopen STDOUT
+ STDOUT.sync = true
# set pid if requested
- if @options[:pid]
+ if @options[:pid] # and as deamon
God.pid = @options[:pid]
end
unless @options[:syslog]
Logger.syslog = false
end
- if @options[:events]
- God::EventHandler.load
- end
+ default_run
- # load config
- if @options[:config]
- # set log level, defaults to WARN
- if @options[:log_level]
- God.log_level = @options[:log_level]
- else
- God.log_level = :warn
- end
-
- unless File.exist?(@options[:config])
- abort "File not found: #{@options[:config]}"
- end
-
- # start the event handler
- God::EventHandler.start if God::EventHandler.loaded?
-
- begin
- load File.expand_path(@options[:config])
- rescue Exception => e
- if e.instance_of?(SystemExit)
- raise
- else
- puts e.message
- puts e.backtrace.join("\n")
- abort "There was an error in your configuration file (see above)"
- end
- end
+ unless God::EventHandler.loaded?
+ puts
+ puts "***********************************************************************"
+ puts "*"
+ puts "* Event conditions are not available for your installation of god."
+ puts "* You may still use and write custom conditions using the poll system"
+ puts "*"
+ puts "***********************************************************************"
+ puts
end
- # reset file descriptors
- STDIN.reopen "/dev/null"
- STDOUT.reopen(log_file, "a")
- STDERR.reopen STDOUT
- STDOUT.sync = true
rescue => e
puts e.message
puts e.backtrace.join("\n")
@@ -127,59 +141,35 @@ def run_daemonized
exit
end
- def run_in_front
- require 'god'
-
- # start attached pid watcher if necessary
- if @options[:attach]
- self.attach
- end
-
- if @options[:port]
- God.port = @options[:port]
- end
-
- if @options[:events]
- God::EventHandler.load
- end
-
- # set log level if requested
- if @options[:log_level]
- God.log_level = @options[:log_level]
- end
-
- if @options[:config]
- unless File.exist?(@options[:config])
- abort "File not found: #{@options[:config]}"
+ def load_config(config)
+ if File.directory? config
+ files_loaded = false
+ Dir[File.expand_path('**/*.god', config)].each do |god_file|
+ files_loaded ||= load_god_file(File.expand_path(god_file))
end
-
- # start the event handler
- God::EventHandler.start if God::EventHandler.loaded?
-
- begin
- load File.expand_path(@options[:config])
- rescue Exception => e
- if e.instance_of?(SystemExit)
- raise
- else
- puts e.message
- puts e.backtrace.join("\n")
- abort "There was an error in your configuration file (see above)"
- end
+ unless files_loaded
+ abort "No files could be loaded"
end
-
- if @options[:log]
- log_file = File.expand_path(@options[:log])
- puts "Sending output to log file: #{log_file}"
-
- # reset file descriptors
- STDIN.reopen "/dev/null"
- STDOUT.reopen(log_file, "a")
- STDERR.reopen STDOUT
- STDOUT.sync = true
+ else
+ unless load_god_file(File.expand_path(config))
+ abort "File could not be loaded"
end
end
end
+
+ def load_god_file(god_file)
+ load File.expand_path(god_file)
+ rescue Exception => e
+ if e.instance_of?(SystemExit)
+ raise
+ else
+ puts "There was an error in #{god_file}"
+ puts "\t" + e.message
+ puts "\t" + e.backtrace.join("\n\t")
+ return false
+ end
+ end
+
end # Run
end
@@ -50,12 +50,12 @@ def reset
end
def pid
- self.watch.pid || File.read(self.pid_file).strip.to_i
+ self.pid_file ? File.read(self.pid_file).strip.to_i : self.watch.pid
end
def valid?
valid = true
- valid &= complain("Attribute 'pid_file' must be specified", self) if self.watch.pid_file.nil? && self.pid_file.nil?
+ valid &= complain("Attribute 'pid_file' must be specified", self) if self.pid_file.nil? && self.watch.pid_file.nil?
valid &= complain("Attribute 'above' must be specified", self) if self.above.nil?
valid
end
@@ -52,12 +52,12 @@ def reset
end
def pid
- self.watch.pid || File.read(self.pid_file).strip.to_i
+ self.pid_file ? File.read(self.pid_file).strip.to_i : self.watch.pid
end
def valid?
valid = true
- valid &= complain("Attribute 'pid_file' must be specified", self) if self.watch.pid_file.nil? && self.pid_file.nil?
+ valid &= complain("Attribute 'pid_file' must be specified", self) if self.pid_file.nil? && self.watch.pid_file.nil?
valid &= complain("Attribute 'above' must be specified", self) if self.above.nil?
valid
end
Oops, something went wrong.

0 comments on commit ba98fdc

Please sign in to comment.