class ThinkingSphinx::RakeInterface

Public Instance Methods

clear_all() click to toggle source
# File lib/thinking_sphinx/rake_interface.rb, line 2
def clear_all
  [
    configuration.indices_location,
    configuration.searchd.binlog_path
  ].each do |path|
    FileUtils.rm_r(path) if File.exists?(path)
  end
end
clear_real_time() click to toggle source
# File lib/thinking_sphinx/rake_interface.rb, line 11
def clear_real_time
  indices = configuration.indices.select { |index| index.type == 'rt' }
  indices.each do |index|
    index.render
    Dir["#{index.path}.*"].each { |path| FileUtils.rm path }
  end

  path = configuration.searchd.binlog_path
  FileUtils.rm_r(path) if File.exists?(path)
end
configure() click to toggle source
# File lib/thinking_sphinx/rake_interface.rb, line 22
def configure
  puts "Generating configuration to #{configuration.configuration_file}"
  configuration.render_to_file
end
generate() click to toggle source
# File lib/thinking_sphinx/rake_interface.rb, line 27
def generate
  indices = configuration.indices.select { |index| index.type == 'rt' }
  indices.each do |index|
    ThinkingSphinx::RealTime::Populator.populate index
  end
end
index(reconfigure = true, verbose = true) click to toggle source
# File lib/thinking_sphinx/rake_interface.rb, line 34
def index(reconfigure = true, verbose = true)
  configure if reconfigure
  FileUtils.mkdir_p configuration.indices_location
  ThinkingSphinx.before_index_hooks.each { |hook| hook.call }
  controller.index :verbose => verbose
end
prepare() click to toggle source
# File lib/thinking_sphinx/rake_interface.rb, line 41
def prepare
  configuration.preload_indices
  configuration.render

  FileUtils.mkdir_p configuration.indices_location
end
start() click to toggle source
# File lib/thinking_sphinx/rake_interface.rb, line 48
def start
  raise RuntimeError, 'searchd is already running' if controller.running?

  FileUtils.mkdir_p configuration.indices_location
  controller.start

  if controller.running?
    puts "Started searchd successfully (pid: #{controller.pid})."
  else
    puts "Failed to start searchd. Check the log files for more information."
  end
end
status() click to toggle source
# File lib/thinking_sphinx/rake_interface.rb, line 61
def status
  if controller.running?
    puts "The Sphinx daemon searchd is currently running."
  else
    puts "The Sphinx daemon searchd is not currently running."
  end
end
stop() click to toggle source
# File lib/thinking_sphinx/rake_interface.rb, line 69
def stop
  unless controller.running?
    puts 'searchd is not currently running.' and return
  end

  pid = controller.pid
  until controller.stop do
    sleep(0.5)
  end

  puts "Stopped searchd daemon (pid: #{pid})."
end

Private Instance Methods

configuration() click to toggle source
# File lib/thinking_sphinx/rake_interface.rb, line 86
def configuration
  ThinkingSphinx::Configuration.instance
end