Class: Droonga::Command::DroongaEngine::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/droonga/command/droonga_engine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/droonga/command/droonga_engine.rb', line 95

def initialize
  @config = nil

  @host = nil
  @port = nil
  @tag  = nil

  @internal_connection_lifetime = nil

  @log_level       = nil
  @log_file        = nil
  @daemon          = nil
  @pid_file_path   = nil
  @ready_notify_fd = nil

  @listen_fd       = nil
  @heartbeat_fd    = nil
  @serf_agent_pid  = nil
end

Instance Attribute Details

#ready_notify_fdObject (readonly)

Returns the value of attribute ready_notify_fd.



94
95
96
# File 'lib/droonga/command/droonga_engine.rb', line 94

def ready_notify_fd
  @ready_notify_fd
end

Instance Method Details

#add_command_line_options(parser) ⇒ Object



193
194
195
196
197
198
199
200
# File 'lib/droonga/command/droonga_engine.rb', line 193

def add_command_line_options(parser)
  add_connection_options(parser)
  add_log_options(parser)
  add_process_options(parser)
  add_path_options(parser)
  add_notification_options(parser)
  add_internal_options(parser)
end

#address_familyObject



119
120
121
122
# File 'lib/droonga/command/droonga_engine.rb', line 119

def address_family
  ip_address = IPAddr.new(IPSocket.getaddress(host))
  ip_address.family
end

#daemon?Boolean

Returns:

  • (Boolean)


154
155
156
157
158
159
# File 'lib/droonga/command/droonga_engine.rb', line 154

def daemon?
  daemon = @daemon
  daemon = config["daemon"] if daemon.nil?
  daemon = false if daemon.nil?
  daemon
end

#engine_nameObject



115
116
117
# File 'lib/droonga/command/droonga_engine.rb', line 115

def engine_name
  "#{host}:#{port}/#{tag}"
end

#heartbeat_socketObject



206
207
208
# File 'lib/droonga/command/droonga_engine.rb', line 206

def heartbeat_socket
  @heartbeat_socket ||= create_heartbeat_socket
end

#hostObject



124
125
126
# File 'lib/droonga/command/droonga_engine.rb', line 124

def host
  @host || config["host"] || default_host
end

#internal_connection_lifetimeObject



136
137
138
139
140
# File 'lib/droonga/command/droonga_engine.rb', line 136

def internal_connection_lifetime
  @internal_connection_lifetime ||
    config["internal_connection_lifetime"] ||
    default_internal_connection_lifetime
end

#listen_socketObject



202
203
204
# File 'lib/droonga/command/droonga_engine.rb', line 202

def listen_socket
  @listen_socket ||= create_listen_socket
end

#log_file_pathObject



146
147
148
# File 'lib/droonga/command/droonga_engine.rb', line 146

def log_file_path
  @log_file_path || config["log_file"] || default_log_file_path
end

#log_levelObject



142
143
144
# File 'lib/droonga/command/droonga_engine.rb', line 142

def log_level
  @log_level || config["log_level"] || default_log_level
end

#pid_file_pathObject



150
151
152
# File 'lib/droonga/command/droonga_engine.rb', line 150

def pid_file_path
  @pid_file_path || config["pid_file"] || default_pid_file_path
end

#portObject



128
129
130
# File 'lib/droonga/command/droonga_engine.rb', line 128

def port
  @port || config["port"] || default_port
end

#serf_agent_pidObject



210
211
212
# File 'lib/droonga/command/droonga_engine.rb', line 210

def serf_agent_pid
  @serf_agent_pid
end

#tagObject



132
133
134
# File 'lib/droonga/command/droonga_engine.rb', line 132

def tag
  @tag || config["tag"] || default_tag
end

#to_engine_command_lineObject



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/droonga/command/droonga_engine.rb', line 161

def to_engine_command_line
  command_line_options = [
    "--host", host,
    "--port", port.to_s,
    "--tag", tag,
    "--internal-connection-lifetime",
      internal_connection_lifetime.to_s,
    "--log-level", log_level,
  ]
  if log_file_path
    command_line_options.concat(["--log-file", log_file_path.to_s])
  end
  if pid_file_path
    command_line_options.concat(["--pid-file", pid_file_path.to_s])
  end
  if daemon?
    command_line_options << "--daemon"
  else
    command_line_options << "--no-daemon"
  end
  command_line_options
end

#to_service_command_lineObject



184
185
186
187
188
189
190
191
# File 'lib/droonga/command/droonga_engine.rb', line 184

def to_service_command_line
  command_line_options = [
    "--engine-name", engine_name,
    "--internal-connection-lifetime",
      internal_connection_lifetime.to_s,
  ]
  command_line_options
end