Skip to content

Commit

Permalink
Fixed an issue with DaemonKit.config.pid_file not having a default in…
Browse files Browse the repository at this point in the history
…stance number, closes #57
  • Loading branch information
kennethkalmer committed Sep 16, 2013
1 parent ef4573a commit b97394f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 7 additions & 6 deletions lib/daemon_kit/initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,9 @@ def at_shutdown( proc = nil, &block )
@shutdown_hooks << ( proc || block )
end

def pid_file( instance = nil )
@pid_file ||= "#{File.dirname(self.log_path)}/#{self.daemon_name}.#{instance}.pid"
def pid_file( instance = instance )
@pid_file ||=
File.join( File.dirname(self.default_log_path), "#{self.daemon_name}.#{instance}.pid" )
end

def instance
Expand All @@ -355,6 +356,10 @@ def run_traps( signal )
self.signal_traps[ signal ].each { |trap| trap.call }
end

def default_log_path
File.join(root_path, 'log', "#{environment}.log")
end

private

def set_trap( signal )
Expand Down Expand Up @@ -412,10 +417,6 @@ def default_load_paths
[ 'lib' ]
end

def default_log_path
File.join(root_path, 'log', "#{environment}.log")
end

def default_log_level
environment == 'production' ? :info : :debug
end
Expand Down
5 changes: 4 additions & 1 deletion spec/initializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
end

it "should have a default pid file" do
subject.pid_file.should_not be_nil
subject.stub(:default_log_path).and_return('/var/log/daemon.log')
subject.stub(:daemon_name).and_return('spec-daemon')

subject.pid_file.should == "/var/log/spec-daemon.1.pid"
end

it "should set a default umask" do
Expand Down

0 comments on commit b97394f

Please sign in to comment.