Class: Droonga::Command::DroongaEngine::Configuration
- Inherits:
-
Object
- Object
- Droonga::Command::DroongaEngine::Configuration
- Defined in:
- lib/droonga/command/droonga_engine.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#log_file ⇒ Object
Returns the value of attribute log_file.
-
#pid_file_path ⇒ Object
Returns the value of attribute pid_file_path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#ready_notify_fd ⇒ Object
readonly
Returns the value of attribute ready_notify_fd.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #add_command_line_options(parser) ⇒ Object
- #address_family ⇒ Object
- #daemon? ⇒ Boolean
- #engine_name ⇒ Object
- #have_config_file? ⇒ Boolean
- #heartbeat_socket ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #listen_socket ⇒ Object
- #load_config ⇒ Object
- #log_level ⇒ Object
- #log_level=(level) ⇒ Object
- #to_command_line ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/droonga/command/droonga_engine.rb', line 118 def initialize config = load_config @host = config["host"] || Address::DEFAULT_HOST @port = config["port"] || Address::DEFAULT_PORT @tag = config["tag"] || Address::DEFAULT_TAG @log_file = nil @daemon = false @pid_file_path = nil @ready_notify_fd = nil if have_config_file? self.pid_file_path = config["pid_file"] if config["pid_file"] self.log_file = config["log_file"] || Path.default_log_file self.log_level = config["log_level"] if config.include?("log_level") end end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
116 117 118 |
# File 'lib/droonga/command/droonga_engine.rb', line 116 def host @host end |
#log_file ⇒ Object
Returns the value of attribute log_file.
116 117 118 |
# File 'lib/droonga/command/droonga_engine.rb', line 116 def log_file @log_file end |
#pid_file_path ⇒ Object
Returns the value of attribute pid_file_path.
116 117 118 |
# File 'lib/droonga/command/droonga_engine.rb', line 116 def pid_file_path @pid_file_path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
116 117 118 |
# File 'lib/droonga/command/droonga_engine.rb', line 116 def port @port end |
#ready_notify_fd ⇒ Object (readonly)
Returns the value of attribute ready_notify_fd.
117 118 119 |
# File 'lib/droonga/command/droonga_engine.rb', line 117 def ready_notify_fd @ready_notify_fd end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
116 117 118 |
# File 'lib/droonga/command/droonga_engine.rb', line 116 def tag @tag end |
Instance Method Details
#add_command_line_options(parser) ⇒ Object
185 186 187 188 189 190 191 |
# File 'lib/droonga/command/droonga_engine.rb', line 185 def (parser) (parser) (parser) (parser) (parser) (parser) end |
#address_family ⇒ Object
153 154 155 156 |
# File 'lib/droonga/command/droonga_engine.rb', line 153 def address_family ip_address = IPAddr.new(IPSocket.getaddress(@host)) ip_address.family end |
#daemon? ⇒ Boolean
174 175 176 |
# File 'lib/droonga/command/droonga_engine.rb', line 174 def daemon? @daemon end |
#engine_name ⇒ Object
149 150 151 |
# File 'lib/droonga/command/droonga_engine.rb', line 149 def engine_name "#{@host}:#{@port}/#{@tag}" end |
#have_config_file? ⇒ Boolean
137 138 139 |
# File 'lib/droonga/command/droonga_engine.rb', line 137 def have_config_file? File.exist?(Path.config) end |
#heartbeat_socket ⇒ Object
197 198 199 |
# File 'lib/droonga/command/droonga_engine.rb', line 197 def heartbeat_socket @heartbeat_socket ||= bind_heartbeat_socket end |
#listen_socket ⇒ Object
193 194 195 |
# File 'lib/droonga/command/droonga_engine.rb', line 193 def listen_socket @listen_socket ||= TCPServer.new(@host, @port) end |
#load_config ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/droonga/command/droonga_engine.rb', line 141 def load_config if have_config_file? YAML.load_file(Path.config) else {} end end |
#log_level ⇒ Object
158 159 160 |
# File 'lib/droonga/command/droonga_engine.rb', line 158 def log_level ENV["DROONGA_LOG_LEVEL"] || Logger::Level.default end |
#log_level=(level) ⇒ Object
162 163 164 |
# File 'lib/droonga/command/droonga_engine.rb', line 162 def log_level=(level) ENV["DROONGA_LOG_LEVEL"] = level end |
#to_command_line ⇒ Object
178 179 180 181 182 183 |
# File 'lib/droonga/command/droonga_engine.rb', line 178 def to_command_line = [ "--engine-name", engine_name, ] end |