Class: ThinkingSphinx::RakeInterface
- Inherits:
-
Object
- Object
- ThinkingSphinx::RakeInterface
- Defined in:
- lib/thinking_sphinx/rake_interface.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #configure ⇒ Object
- #generate ⇒ Object
- #index(reconfigure = true) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Instance Method Details
#clear ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/thinking_sphinx/rake_interface.rb', line 2 def clear [ configuration.indices_location, configuration.searchd.binlog_path ].each do |path| FileUtils.rm_r(path) if File.exists?(path) end end |
#configure ⇒ Object
11 12 13 14 |
# File 'lib/thinking_sphinx/rake_interface.rb', line 11 def configure puts "Generating configuration to #{configuration.configuration_file}" configuration.render_to_file end |
#generate ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/thinking_sphinx/rake_interface.rb', line 16 def generate configuration.preload_indices configuration.render FileUtils.mkdir_p configuration.indices_location indices = configuration.indices.select { |index| index.type == 'rt' } indices.each do |index| ThinkingSphinx::RealTime::Populator.populate index end end |
#index(reconfigure = true) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/thinking_sphinx/rake_interface.rb', line 28 def index(reconfigure = true) configure if reconfigure FileUtils.mkdir_p configuration.indices_location ThinkingSphinx.before_index_hooks.each { |hook| hook.call } controller.index :verbose => true end |
#start ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/thinking_sphinx/rake_interface.rb', line 35 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 |
#stop ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/thinking_sphinx/rake_interface.rb', line 48 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 |