Sha256: 7f5fbbfca0d3a513e4a631fd40510fc9433f9555bb7f43d61c5222b8c943e4da
Contents?: true
Size: 1.14 KB
Versions: 9
Compression:
Stored size: 1.14 KB
Contents
module Riddle class Controller def initialize(configuration, path) @configuration = configuration @path = path end def index(*indexes) indexes << '--all' if indexes.empty? cmd = "indexer --config #{@path} #{indexes.join(' ')}" cmd << " --rotate" if running? `#{cmd}` end def start return if running? cmd = "searchd --pidfile --config #{@path}" if RUBY_PLATFORM =~ /mswin/ system("start /B #{cmd} 1> NUL 2>&1") else `#{cmd}` end sleep(1) unless running? puts "Failed to start searchd daemon. Check #{@configuration.searchd.log}." end end def stop return unless running? Process.kill('SIGTERM', pid.to_i) rescue Errno::EINVAL Process.kill('SIGKILL', pid.to_i) end def pid if File.exists?(@configuration.searchd.pid_file) File.read(@configuration.searchd.pid_file)[/\d+/] else nil end end def running? !!pid && !!Process.kill(0, pid.to_i) rescue false end end end
Version data entries
9 entries across 9 versions & 4 rubygems