Navigation Menu

Skip to content

Commit

Permalink
droonga-engine: re-support valid default value
Browse files Browse the repository at this point in the history
  • Loading branch information
kou authored and piroor committed Jan 6, 2015
1 parent e7ed9c6 commit 75614ca
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions lib/droonga/command/droonga_engine.rb
Expand Up @@ -137,27 +137,27 @@ def address_family
end

def host
@host || config["host"] || Address::DEFAULT_HOST
@host || config["host"] || default_host
end

def port
@port || config["port"] || Address::DEFAULT_PORT
@port || config["port"] || default_port
end

def tag
@port || config["tag"] || Address::DEFAULT_TAG
@port || config["tag"] || default_tag
end

def log_level
ENV["DROONGA_LOG_LEVEL"] || config["log_level"] || Logger::Level.default
ENV["DROONGA_LOG_LEVEL"] || config["log_level"] || default_log_level
end

def log_level=(level)
ENV["DROONGA_LOG_LEVEL"] = level
end

def log_file
file = @log_file || config["log_file"] || Path.default_log_file
file = @log_file || config["log_file"] || default_log_file
File.expand_path(file)
end

Expand All @@ -166,7 +166,7 @@ def log_file=(file)
end

def pid_file_path
path = @pid_file_path || config["pid_file"]
path = @pid_file_path || config["pid_file"] || default_pid_file_path
return nil if path.nil?
Pathname.new(path.to_s).expand_path
end
Expand Down Expand Up @@ -206,6 +206,30 @@ def heartbeat_socket
end

private
def default_host
Address::DEFAULT_HOST
end

def default_port
Address::DEFAULT_PORT
end

def default_tag
Address::DEFAULT_TAG
end

def default_log_level
ENV["DROONGA_LOG_LEVEL"] || Logger::Level.default
end

def default_log_file
Path.default_log_file
end

def default_pid_file_path
nil
end

def config
@config ||= load_config
end
Expand All @@ -224,17 +248,17 @@ def add_connection_options(parser)
parser.separator("Connection:")
parser.on("--host=HOST",
"The host name of the Droonga engine",
"(#{@host})") do |host|
"(#{default_host})") do |host|
@host = host
end
parser.on("--port=PORT", Integer,
"The port number of the Droonga engine",
"(#{@port})") do |port|
"(#{default_port})") do |port|
@port = port
end
parser.on("--tag=TAG",
"The tag of the Droonga engine",
"(#{@tag})") do |tag|
"(#{default_tag})") do |tag|
@tag = tag
end
end
Expand Down

0 comments on commit 75614ca

Please sign in to comment.