Sha256: 87f8bc9d5ff6ddebd758f11eb5d61930511c3ba4ce9a5804c96e3b36fa2d6f7f

Contents?: true

Size: 846 Bytes

Versions: 36

Compression:

Stored size: 846 Bytes

Contents

module Riddle
  class Controller
    def initialize(configuration, path)
      @configuration  = configuration
      @path           = path
    end
    
    def index
      cmd = "indexer --config #{@path} --all"
      cmd << " --rotate" if running?
      `#{cmd}`
    end
    
    def start
      return if running?

      cmd = "searchd --pidfile --config #{@path}"
      `#{cmd}`    

      sleep(1)

      unless running?
        puts "Failed to start searchd daemon. Check #{@configuration.searchd.log}."
      end
    end

    def stop
      return unless running?
      `kill #{pid}`
    end

    def pid
      if File.exists?("#{@configuration.searchd.pid_file}")
        `cat #{@configuration.searchd.pid_file}`[/\d+/]
      else
        nil
      end
    end

    def running?
      pid && `ps #{pid} | wc -l`.to_i > 1
    end
  end
end

Version data entries

36 entries across 36 versions & 8 rubygems

Version Path
DrMark-thinking-sphinx-1.1.14 vendor/riddle/lib/riddle/controller.rb
DrMark-thinking-sphinx-1.1.15 vendor/riddle/lib/riddle/controller.rb
DrMark-thinking-sphinx-1.1.6 vendor/riddle/lib/riddle/controller.rb
dpickett-thinking-sphinx-1.1.12 vendor/riddle/lib/riddle/controller.rb
dpickett-thinking-sphinx-1.1.23 vendor/riddle/lib/riddle/controller.rb
dpickett-thinking-sphinx-1.1.4 vendor/riddle/lib/riddle/controller.rb
ebeigarts-thinking-sphinx-1.1.21 vendor/riddle/lib/riddle/controller.rb
ebeigarts-thinking-sphinx-1.1.22 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.10 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.11 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.12 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.14 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.15 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.16 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.17 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.18 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.19 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.20 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.21 vendor/riddle/lib/riddle/controller.rb
freelancing-god-thinking-sphinx-1.1.22 vendor/riddle/lib/riddle/controller.rb