daemon_controller + Thinking Sphinx
by Michał Kuklis on 22/07/2009I’ve created simple rails initiator in order to start Sphinx through daemon_controller based on the Thinking Sphinx configuration. I hope it will help somebody.
require 'daemon_controller' def before_start if not ThinkingSphinx.define_indexes? config = ThinkingSphinx::Configuration.instance cmd = "#{config.bin_path}#{config.indexer_binary_name} --config \"#{config.config_file}\" --all" cmd << " --rotate" if ThinkingSphinx.sphinx_running? system cmd end end if defined?(ThinkingSphinx) if not ThinkingSphinx.sphinx_running? conf_instance = ThinkingSphinx::Configuration.instance @controller = DaemonController.new( :identifier => 'Sphinx search server', :start_command => "#{conf_instance.bin_path}#{conf_instance.searchd_binary_name} --pidfile --config \"#{conf_instance.config_file}\"", :before_start => method(:before_start), :ping_command => lambda { TCPSocket.new(conf_instance.configuration.searchd.address, conf_instance.configuration.searchd.port) }, :pid_file => conf_instance.configuration.searchd.pid_file, :log_file => conf_instance.configuration.searchd.log) @controller.start end end
There are 4 comments in this article: