Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Fixed PID handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShogunPanda committed Sep 26, 2013
1 parent 19512c3 commit 9bad4d2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
19 changes: 17 additions & 2 deletions lib/devdnsd/application.rb
Expand Up @@ -24,16 +24,31 @@ def daemon_name
# Returns the standard location of the PID file.
#
# @return [String] The standard location of the PID file.
def pid_directory
def working_directory
File.dirname(instance.config.pid_file)
end
alias_method :runtime_directory, :working_directory

# Returns the complete path of the PID file.
#
# @return [String] The complete path of the PID file.
def pid_fn
def process_file_path
instance.config.pid_file
end

# Returns the complete path of the log file.
#
# @return [String] The complete path of the log file.
def log_file_path
instance.config.log_file
end

# Returns the standard location of the log file.
#
# @return [String] The standard location of the log file.
def log_directory
File.dirname(instance.config.log_file)
end
end

# Gets the path for the resolver file.
Expand Down
2 changes: 1 addition & 1 deletion lib/devdnsd/version.rb
Expand Up @@ -16,7 +16,7 @@ module Version
MINOR = 0

# The patch version.
PATCH = 4
PATCH = 5

# The current version number of DevDNSd.
STRING = [MAJOR, MINOR, PATCH].compact.join(".")
Expand Down
38 changes: 32 additions & 6 deletions spec/devdnsd/application_spec.rb
Expand Up @@ -112,29 +112,55 @@ def create_application(overrides = {})
end
end

describe ".pid_fn" do
describe ".process_file_path" do
let(:application){ create_application({"log_file" => log_file, "configuration" => sample_config}) }

it "returns the default file" do
expect(DevDNSd::Application.pid_fn).to eq("/var/run/devdnsd.pid")
expect(DevDNSd::Application.process_file_path).to eq("/var/run/devdnsd.pid")
end

it "return the set file" do
DevDNSd::Application.instance.config.pid_file = "/this/is/a/daemon.pid"
expect(DevDNSd::Application.pid_fn).to eq("/this/is/a/daemon.pid")
expect(DevDNSd::Application.process_file_path).to eq("/this/is/a/daemon.pid")
end
end

describe ".pid_directory" do
describe ".log_file_path" do
let(:application){ create_application({"log_file" => log_file, "configuration" => sample_config}) }

it "returns the default file" do
expect(DevDNSd::Application.log_file_path).to eq(log_file)
end

it "return the set file" do
DevDNSd::Application.instance.config.log_file = "/this/is/a/daemon.log"
expect(DevDNSd::Application.log_file_path).to eq("/this/is/a/daemon.log")
end
end

describe ".working_directory" do
let(:application){ create_application({"log_file" => log_file, "configuration" => sample_config}) }

it "returns the default path" do
expect(DevDNSd::Application.pid_directory).to eq("/var/run")
expect(DevDNSd::Application.working_directory).to eq("/var/run")
end

it "return the set path basing on the PID file" do
DevDNSd::Application.instance.config.pid_file = "/this/is/a/daemon.pid"
expect(DevDNSd::Application.pid_directory).to eq("/this/is/a")
expect(DevDNSd::Application.working_directory).to eq("/this/is/a")
end
end

describe ".log_directory" do
let(:application){ create_application({"log_file" => log_file, "configuration" => sample_config}) }

it "returns the default path" do
expect(DevDNSd::Application.log_directory).to eq(File.dirname(log_file))
end

it "return the set path basing on the PID file" do
DevDNSd::Application.instance.config.log_file = "/this/is/a/daemon.log"
expect(DevDNSd::Application.log_directory).to eq("/this/is/a")
end
end

Expand Down

0 comments on commit 9bad4d2

Please sign in to comment.