From e938f41f1f76e8e2abd12c8331d5499cb9081b6e Mon Sep 17 00:00:00 2001 From: Tom Werner Date: Fri, 26 Oct 2007 11:50:20 -0700 Subject: [PATCH] remove gods pid file on user requested termination --- History.txt | 16 ++++++++++++++++ bin/god | 5 +++++ lib/god.rb | 5 ++++- test/test_god.rb | 9 +++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/History.txt b/History.txt index 32ae08d..ae4e98c 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,19 @@ +== 0.6.0 / + +* Minor Enhancement + * Move Syslog calls into God::Logger and clean up all calling code + * Remove god's pid file on user requested termination + +== 0.5.2 / 2007-10-10 + +* Minor Enhancement + * Allow extra args to pass through to config file + +== 0.5.1 / 2007-10-08 + +* Bug Fixes + * Rescue connection refused in http response code condition + == 0.5.0 / 2007-10-05 * Major Enhancements diff --git a/bin/god b/bin/god index 754a09a..3b1011f 100755 --- a/bin/god +++ b/bin/god @@ -252,6 +252,11 @@ begin God.port = options[:port] end + # set pid if requested + if options[:pid] + God.pid = options[:pid] + end + # load config if options[:config] unless File.exist?(options[:config]) diff --git a/lib/god.rb b/lib/god.rb index 16524e6..8ba41a4 100644 --- a/lib/god.rb +++ b/lib/god.rb @@ -134,7 +134,8 @@ module God class << self # user configurable - safe_attr_accessor :host, + safe_attr_accessor :pid, + :host, :port, :allow, :log_buffer_size, @@ -153,6 +154,7 @@ module God end # initialize class instance variables + self.pid = nil self.host = nil self.port = nil self.allow = nil @@ -361,6 +363,7 @@ module God end def self.terminate + FileUtils.rm_f(self.pid) if self.pid exit!(0) end diff --git a/test/test_god.rb b/test/test_god.rb index 1f3fc29..246bda1 100644 --- a/test/test_god.rb +++ b/test/test_god.rb @@ -336,6 +336,15 @@ class TestGod < Test::Unit::TestCase # terminate def test_terminate_should_exit + God.pid = nil + FileUtils.expects(:rm_f).never + God.expects(:exit!) + God.terminate + end + + def test_terminate_should_delete_pid + God.pid = '/foo/bar' + FileUtils.expects(:rm_f).with("/foo/bar") God.expects(:exit!) God.terminate end -- 2.11.4.GIT