god 0.7.3 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,18 @@
1
+ == 0.7.5 / 2008-02-21
2
+ * Bug Fixes
3
+ * Remove Ruby's Logger and replace with custom SimpleLogger to stop threaded leak
4
+
5
+ == 0.7.4 / 2008-02-18
6
+ * Bug Fixes
7
+ * Introduce local scope to prevent faulty optimization that causes memory to leak
8
+
1
9
  == 0.7.3 / 2008-02-14
2
10
  * Minor Enhancements
3
11
  * Add --bleakhouse to make running diagnostics easier
4
12
  * Bug Fixes
5
- * Use ::Process.kill(0, ...) instead of `kill -0`
6
- * Fix pid_file behavior in process-centric conditions so they work with tasks
7
- * Redirect output of daemonized god to log file or /dev/null earlier
13
+ * Use ::Process.kill(0, ...) instead of `kill -0` [queso]
14
+ * Fix pid_file behavior in process-centric conditions so they work with tasks [matias]
15
+ * Redirect output of daemonized god to log file or /dev/null earlier [_eric]
8
16
 
9
17
  == 0.7.2 / 2008-02-04
10
18
  * Bug Fixes
@@ -45,6 +45,7 @@ lib/god/logger.rb
45
45
  lib/god/metric.rb
46
46
  lib/god/process.rb
47
47
  lib/god/registry.rb
48
+ lib/god/simple_logger.rb
48
49
  lib/god/socket.rb
49
50
  lib/god/sugar.rb
50
51
  lib/god/system/process.rb
@@ -67,6 +68,7 @@ test/configs/daemon_polls/daemon_polls.god
67
68
  test/configs/daemon_polls/simple_server.rb
68
69
  test/configs/degrading_lambda/degrading_lambda.god
69
70
  test/configs/degrading_lambda/tcp_server.rb
71
+ test/configs/matias/matias.god
70
72
  test/configs/real.rb
71
73
  test/configs/running_load/running_load.god
72
74
  test/configs/stress/simple_server.rb
data/README.txt CHANGED
@@ -24,12 +24,20 @@ Sign up for the god mailing list at http://groups.google.com/group/god-rb
24
24
  == INSTALL:
25
25
 
26
26
  $ sudo gem install god
27
+
28
+ == CONTRIBUTE:
29
+
30
+ Latest code is available at http://github.com/mojombo/god
31
+
32
+ The 'master' branch can be cloned with:
33
+
34
+ $ git clone git://github.com/mojombo/god.git
27
35
 
28
36
  == LICENSE:
29
37
 
30
38
  (The MIT License)
31
39
 
32
- Copyright (c) 2007 FIX
40
+ Copyright (c) 2007 Tom Preston-Werner
33
41
 
34
42
  Permission is hereby granted, free of charge, to any person obtaining
35
43
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'hoe'
3
3
 
4
- Hoe.new('god', '0.7.3') do |p|
4
+ Hoe.new('god', '0.7.5') do |p|
5
5
  p.rubyforge_name = 'god'
6
6
  p.author = 'Tom Preston-Werner'
7
7
  p.email = 'tom@rubyisawesome.com'
data/lib/god.rb CHANGED
@@ -5,7 +5,6 @@ require 'rubygems'
5
5
 
6
6
  # core
7
7
  require 'stringio'
8
- require 'logger'
9
8
  require 'fileutils'
10
9
 
11
10
  begin
@@ -19,6 +18,7 @@ end
19
18
 
20
19
  # internal requires
21
20
  require 'god/errors'
21
+ require 'god/simple_logger'
22
22
  require 'god/logger'
23
23
  require 'god/system/process'
24
24
  require 'god/dependency_graph'
@@ -70,7 +70,6 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. ext god])
70
70
 
71
71
  # App wide logging system
72
72
  LOG = God::Logger.new
73
- LOG.datetime_format = "%Y-%m-%d %H:%M:%S "
74
73
 
75
74
  def applog(watch, level, text)
76
75
  LOG.log(watch, level, text)
@@ -130,7 +129,7 @@ class Module
130
129
  end
131
130
 
132
131
  module God
133
- VERSION = '0.7.3'
132
+ VERSION = '0.7.5'
134
133
 
135
134
  LOG_BUFFER_SIZE_DEFAULT = 100
136
135
  PID_FILE_DIRECTORY_DEFAULTS = ['/var/run/god', '~/.god/pids']
@@ -31,6 +31,7 @@ module God
31
31
  end
32
32
 
33
33
  def base_name
34
+ x = 1 # fix for MRI's local scope optimization bug DO NOT REMOVE!
34
35
  self.class.name.split('::').last
35
36
  end
36
37
 
@@ -1,6 +1,6 @@
1
1
  module God
2
2
 
3
- class Logger < ::Logger
3
+ class Logger < SimpleLogger
4
4
  SYSLOG_EQUIVALENTS = {:fatal => :crit,
5
5
  :error => :err,
6
6
  :warn => :debug,
@@ -22,7 +22,7 @@ module God
22
22
  @mutex = Mutex.new
23
23
  @capture = nil
24
24
  @templogio = StringIO.new
25
- @templog = ::Logger.new(@templogio)
25
+ @templog = SimpleLogger.new(@templogio)
26
26
  @templog.level = Logger::INFO
27
27
  load_syslog
28
28
  end
@@ -0,0 +1,53 @@
1
+ module God
2
+
3
+ class SimpleLogger
4
+ DEBUG = 2
5
+ INFO = 4
6
+ WARN = 8
7
+ ERROR = 16
8
+ FATAL = 32
9
+
10
+ SEV_LABEL = {DEBUG => 'DEBUG',
11
+ INFO => 'INFO',
12
+ WARN => 'WARN',
13
+ ERROR => 'ERROR',
14
+ FATAL => 'FATAL'}
15
+
16
+ attr_accessor :datetime_format, :level
17
+
18
+ def initialize(io)
19
+ @io = io
20
+ @level = INFO
21
+ @datetime_format = "%Y-%m-%d %H:%M:%S"
22
+ end
23
+
24
+ def output(level, msg)
25
+ return if level < self.level
26
+
27
+ time = Time.now.strftime(self.datetime_format)
28
+ label = SEV_LABEL[level]
29
+ @io.print("#{label[0..0]} [#{time}] #{label.rjust(5)}: #{msg}\n")
30
+ end
31
+
32
+ def fatal(msg)
33
+ self.output(FATAL, msg)
34
+ end
35
+
36
+ def error(msg)
37
+ self.output(ERROR, msg)
38
+ end
39
+
40
+ def warn(msg)
41
+ self.output(WARN, msg)
42
+ end
43
+
44
+ def info(msg)
45
+ self.output(INFO, msg)
46
+ end
47
+
48
+ def debug(msg)
49
+ self.output(DEBUG, msg)
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,50 @@
1
+ $pid_file = "/tmp/matias.pid"
2
+
3
+ God.task do |w|
4
+ w.name = "watcher"
5
+ w.interval = 5.seconds
6
+ w.valid_states = [:init, :up, :down]
7
+ w.initial_state = :init
8
+
9
+ # determine the state on startup
10
+ w.transition(:init, { true => :up, false => :down }) do |on|
11
+ on.condition(:process_running) do |c|
12
+ c.running = true
13
+ c.pid_file = $pid_file
14
+ end
15
+ end
16
+
17
+ # when process is up
18
+ w.transition(:up, :down) do |on|
19
+ # transition to 'start' if process goes down
20
+ on.condition(:process_running) do |c|
21
+ c.running = false
22
+ c.pid_file = $pid_file
23
+ end
24
+
25
+ # send up info
26
+ on.condition(:lambda) do |c|
27
+ c.lambda = lambda do
28
+ puts 'yay I am up'
29
+ false
30
+ end
31
+ end
32
+ end
33
+
34
+ # when process is down
35
+ w.transition(:down, :up) do |on|
36
+ # transition to 'up' if process comes up
37
+ on.condition(:process_running) do |c|
38
+ c.running = true
39
+ c.pid_file = $pid_file
40
+ end
41
+
42
+ # send down info
43
+ on.condition(:lambda) do |c|
44
+ c.lambda = lambda do
45
+ puts 'boo I am down'
46
+ false
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,8 +1,8 @@
1
- ('01'..'40').each do |i|
1
+ ('01'..'08').each do |i|
2
2
  God.watch do |w|
3
3
  w.name = "stress-#{i}"
4
4
  w.start = "ruby " + File.join(File.dirname(__FILE__), *%w[simple_server.rb])
5
- w.interval = 1
5
+ w.interval = 0
6
6
  w.grace = 2
7
7
  w.group = 'test'
8
8
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: god
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.3
7
- date: 2008-02-13 00:00:00 -08:00
6
+ version: 0.7.5
7
+ date: 2008-05-13 00:00:00 -07:00
8
8
  summary: Like monit, only awesome
9
9
  require_paths:
10
10
  - lib
@@ -77,6 +77,7 @@ files:
77
77
  - lib/god/metric.rb
78
78
  - lib/god/process.rb
79
79
  - lib/god/registry.rb
80
+ - lib/god/simple_logger.rb
80
81
  - lib/god/socket.rb
81
82
  - lib/god/sugar.rb
82
83
  - lib/god/system/process.rb
@@ -99,6 +100,7 @@ files:
99
100
  - test/configs/daemon_polls/simple_server.rb
100
101
  - test/configs/degrading_lambda/degrading_lambda.god
101
102
  - test/configs/degrading_lambda/tcp_server.rb
103
+ - test/configs/matias/matias.god
102
104
  - test/configs/real.rb
103
105
  - test/configs/running_load/running_load.god
104
106
  - test/configs/stress/simple_server.rb