Class: Groonga::Client::Test::GroongaServerRunner
- Inherits:
-
Object
- Object
- Groonga::Client::Test::GroongaServerRunner
- Defined in:
- lib/groonga/client/test/groonga-server-runner.rb
Instance Method Summary collapse
-
#initialize ⇒ GroongaServerRunner
constructor
A new instance of GroongaServerRunner.
- #run ⇒ Object
- #stop ⇒ Object
- #url ⇒ Object
- #using_running_server? ⇒ Boolean
Constructor Details
#initialize ⇒ GroongaServerRunner
Returns a new instance of GroongaServerRunner.
26 27 28 29 30 31 |
# File 'lib/groonga/client/test/groonga-server-runner.rb', line 26 def initialize @pid = nil @using_running_server = false @groonga = find_groonga @tmp_dir = nil end |
Instance Method Details
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/groonga/client/test/groonga-server-runner.rb', line 33 def run if groonga_server_running? @using_running_server = true @dump = open_client do |client| client.dump.body end else return if @groonga.nil? @tmp_dir = create_tmp_dir db_path = @tmp_dir + "db" @pid = spawn(@groonga, "--port", url.port.to_s, "--log-path", (@tmp_dir + "groonga.log").to_s, "--query-log-path", (@tmp_dir + "query.log").to_s, "--protocol", "http", "-s", "-n", db_path.to_s) wait_groonga_ready end end |
#stop ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/groonga/client/test/groonga-server-runner.rb', line 54 def stop if @using_running_server open_client do |client| remove_all(client) restore(client) end else if @pid open_client do |client| client.shutdown end wait_groonga_shutdown end if @tmp_dir FileUtils.rm_rf(@tmp_dir) end end end |
#url ⇒ Object
77 78 79 |
# File 'lib/groonga/client/test/groonga-server-runner.rb', line 77 def url @url ||= build_url end |
#using_running_server? ⇒ Boolean
73 74 75 |
# File 'lib/groonga/client/test/groonga-server-runner.rb', line 73 def using_running_server? @using_running_server end |