Class: DataMapper::Adapters::Sphinx::ManagedClient

Inherits:
Client
  • Object
show all
Defined in:
lib/dm-sphinx-adapter/client.rb

Overview

Managed searchd if you don’t already have god/monit doing the job for you.

Requires you have daemon_controller installed.

See

Instance Method Summary collapse

Methods inherited from Client

#index

Constructor Details

#initialize(url_or_options = {}) ⇒ ManagedClient

See

  • DataMapper::Adapters::Sphinx::Client#new



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/dm-sphinx-adapter/client.rb', line 80

def initialize(url_or_options = {})
  super

  require 'daemon_controller'
  @client = DaemonController.new(
    :identifier    => 'Sphinx searchd',
    :start_command => @config.searchd_bin,
    :stop_command  => "#{@config.searchd_bin} --stop",
    :ping_command  => method(:running?),
    :pid_file      => @config.pid_file,
    :log_file      => @config.log
  )
end

Instance Method Details

#search(*args) ⇒ Object

Start the searchd daemon if it isn’t already running then search.

See

  • DataMapper::Adapters::Sphinx::Client#search



98
99
100
# File 'lib/dm-sphinx-adapter/client.rb', line 98

def search(*args)
  @client.connect{super}
end

#stopObject

Stop the searchd daemon if it’s running.



103
104
105
# File 'lib/dm-sphinx-adapter/client.rb', line 103

def stop
  @client.stop if @client.running?
end