Class: Groonga::QueryLog::Command::RunRegressionTest::GroongaServer
- Inherits:
-
Object
- Object
- Groonga::QueryLog::Command::RunRegressionTest::GroongaServer
- Defined in:
- lib/groonga/query-log/command/run-regression-test.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(groonga, database_path, options) ⇒ GroongaServer
constructor
A new instance of GroongaServer.
- #run ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(groonga, database_path, options) ⇒ GroongaServer
Returns a new instance of GroongaServer.
164 165 166 167 168 169 170 171 172 |
# File 'lib/groonga/query-log/command/run-regression-test.rb', line 164 def initialize(groonga, database_path, ) @input_directory = [:input_directory] || Pathname.new(".") @working_directory = [:working_directory] || Pathname.new(".") @groonga = groonga @database_path = @working_directory + database_path @host = "127.0.0.1" @port = find_unused_port @options = end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
163 164 165 |
# File 'lib/groonga/query-log/command/run-regression-test.rb', line 163 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
163 164 165 |
# File 'lib/groonga/query-log/command/run-regression-test.rb', line 163 def port @port end |
Instance Method Details
#run ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/groonga/query-log/command/run-regression-test.rb', line 174 def run ensure_database return unless @options[:run_queries] @pid = spawn(@groonga, "--bind-address", @host, "--port", @port.to_s, "--log-path", log_path.to_s, "--query-log-path", query_log_path.to_s, "--protocol", "http", "-s", @database_path.to_s) n_retries = 10 begin send_command("status") rescue SystemCallError sleep(1) n_retries -= 1 raise if n_retries.zero? retry end yield end |
#shutdown ⇒ Object
200 201 202 203 204 205 206 |
# File 'lib/groonga/query-log/command/run-regression-test.rb', line 200 def shutdown begin send_command("shutdown") rescue SystemCallError end Process.waitpid(@pid) end |