Skip to content
Browse files

fix byte-centric sugar (kb is canonical not bytes); make god binary p…

…id generation optional
  • Loading branch information...
1 parent 02f9144 commit 9808a334af7cc461c1431b412236a8e5bf3e51a9 @mojombo mojombo committed Aug 14, 2007
Showing with 22 additions and 30 deletions.
  1. +3 −2 History.txt
  2. +5 −0 Rakefile
  3. +4 −7 bin/god
  4. +3 −9 lib/god/sugar.rb
  5. +1 −1 site/index.html
  6. +6 −11 test/test_sugar.rb
View
5 History.txt
@@ -17,9 +17,10 @@
* Enhance god binary with better reporting
* Fix synchronization bug in Timer (reported by Srini Panguluri)
* Add Lambda condition for easy custom conditions [Mike Mintz]
-* Add sugar for numerics (seconds, minutes, bytes, kilobytes, etc)
-* Add PID and log file generation to god binary
+* Add sugar for numerics (seconds, minutes, kilobytes, megabytes, percent, etc)
+* Add optional PID and log file generation to god binary for daemon mode
* Add God.load to do glob enabled loading
+* Add -V option to god binary for detailed version/build info
== 0.2.0 / 2007-07-18
View
5 Rakefile
@@ -25,4 +25,9 @@ task :site do
sh "scp -r site/* mojombo@god.rubyforge.org:/var/www/gforge-projects/god"
end
+desc "Upload site to Rubyforge"
+task :site_edge do
+ sh "scp -r site/* mojombo@god.rubyforge.org:/var/www/gforge-projects/god/edge"
+end
+
# vim: syntax=Ruby
View
11 bin/god
@@ -107,8 +107,6 @@ else
begin
require 'god'
- # Dir.chdir "/"
-
log_file = options[:log] || "/dev/null"
STDIN.reopen "/dev/null"
@@ -129,9 +127,7 @@ else
end
puts "Resetting file descriptors"
-
- # Daemons.daemonize if options[:daemonize]
-
+
puts "Loading config"
load File.expand_path(options[:config])
@@ -141,8 +137,9 @@ else
end
end
- pid_file = options[:pid] || "god.pid"
- File.open(pid_file, 'w') { |f| f.write pid }
+ if options[:pid]
+ File.open(options[:pid], 'w') { |f| f.write pid }
+ end
::Process.detach pid
View
12 lib/god/sugar.rb
@@ -23,26 +23,20 @@ def days
alias :day :days
- def bytes
- self
- end
-
- alias :byte :bytes
-
def kilobytes
- self * 1024
+ self
end
alias :kilobyte :kilobytes
def megabytes
- self * (1024 ** 2)
+ self * 1024
end
alias :megabyte :megabytes
def gigabytes
- self * (1024 ** 3)
+ self * (1024 ** 2)
end
alias :gigabyte :gigabytes
View
2 site/index.html
@@ -332,7 +332,7 @@
...
end</code></pre>
-<p>Similar to <code>start_if</code> there is a <code>restart_if</code> command that groups conditions that should trigger a restart. The <code>memory_usage</code> condition will fail if the specified process is using too much memory. The maximum allowable amount of memory is specified with the <code>above</code> attribute (you can use the bytes, kilobytes, megabytes, or gigabytes helpers). The number of times the test needs to fail in order to trigger a restart is set with <code>times</code>. This can be either an integer or an array. An integer means it must fail that many times in a row while an array [x, y] means it must fail x times out of the last y tests.</p>
+<p>Similar to <code>start_if</code> there is a <code>restart_if</code> command that groups conditions that should trigger a restart. The <code>memory_usage</code> condition will fail if the specified process is using too much memory. The maximum allowable amount of memory is specified with the <code>above</code> attribute (you can use the kilobytes, megabytes, or gigabytes helpers). The number of times the test needs to fail in order to trigger a restart is set with <code>times</code>. This can be either an integer or an array. An integer means it must fail that many times in a row while an array [x, y] means it must fail x times out of the last y tests.</p>
<pre><code class="ruby"> w.restart_if do |restart|
...
View
17 test/test_sugar.rb
@@ -21,24 +21,19 @@ def test_days
assert_equal 86400, 1.day
end
- def test_bytes
- assert_equal 1, 1.bytes
- assert_equal 1, 1.byte
- end
-
def test_kilobytes
- assert_equal 1024, 1.kilobytes
- assert_equal 1024, 1.kilobyte
+ assert_equal 1, 1.kilobytes
+ assert_equal 1, 1.kilobyte
end
def test_megabytes
- assert_equal 1024 ** 2, 1.megabytes
- assert_equal 1024 ** 2, 1.megabyte
+ assert_equal 1024, 1.megabytes
+ assert_equal 1024, 1.megabyte
end
def test_gigabytes
- assert_equal 1024 ** 3, 1.gigabytes
- assert_equal 1024 ** 3, 1.gigabyte
+ assert_equal 1024 ** 2, 1.gigabytes
+ assert_equal 1024 ** 2, 1.gigabyte
end
def test_percent

0 comments on commit 9808a33

Please sign in to comment.
Something went wrong with that request. Please try again.