Skip to content

Commit

Permalink
feat: Add start args for searchd
Browse files Browse the repository at this point in the history
  • Loading branch information
bibendi committed May 10, 2017
1 parent 86d88bb commit 46ce6c8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ module Sphinx::Integration::Extensions::ThinkingSphinx::Configuration

included do
attr_accessor :remote, :user, :password, :exclude, :ssh_port, :ssh_password,
:log_level, :mysql_read_timeout, :mysql_connect_timeout
:log_level, :mysql_read_timeout, :mysql_connect_timeout,
:start_args

alias_method_chain :shuffled_addresses, :integration
alias_method_chain :reset, :integration
Expand Down Expand Up @@ -43,6 +44,7 @@ def reset_with_integration(custom_app_root = nil)
self.mysql_connect_timeout = 2
self.mysql_read_timeout = 5
self.ssh_port = 22
self.start_args = []
@mysql_client = nil

reset_without_integration(custom_app_root)
Expand Down
5 changes: 3 additions & 2 deletions lib/sphinx/integration/helper_adapters/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def stop
end

def start
searchd
searchd(*config.start_args)
end

def suspend
Expand Down Expand Up @@ -61,7 +61,8 @@ def reload
private

def searchd(*params)
logger.info Rye.shell(:searchd, "--config #{config.config_file}", *params).inspect
cmd_args = [:searchd, "--config #{config.config_file}"] + params
logger.info Rye.shell(*cmd_args).inspect
end

def indexer(*params)
Expand Down
3 changes: 2 additions & 1 deletion lib/sphinx/integration/helper_adapters/remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def stop
end

def start
@ssh.execute("searchd", "--config #{config.config_file}")
args = ["searchd", "--config #{config.config_file}"] + config.start_args
@ssh.execute(*args)
end

def suspend
Expand Down
6 changes: 6 additions & 0 deletions spec/sphinx/integration/helper_adapters/local_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
expect(rye).to receive(:shell).with(:searchd, /--config/)
adapter.start
end

it "starts searchd with start_args" do
stub_sphinx_conf(start_args: ["--cpustats"])
expect(rye).to receive(:shell).with(:searchd, /--config/, "--cpustats")
adapter.start
end
end

describe "#remove_indexes" do
Expand Down
6 changes: 6 additions & 0 deletions spec/sphinx/integration/helper_adapters/remote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
expect(ssh).to receive(:execute).with("searchd", /--config/)
adapter.start
end

it "starts searchd with start_args" do
stub_sphinx_conf(start_args: ["--cpustats"])
expect(ssh).to receive(:execute).with("searchd", /--config/, "--cpustats")
adapter.start
end
end

describe "#suspend" do
Expand Down

0 comments on commit 46ce6c8

Please sign in to comment.