Sha256: 9ee17c2767c38076edc4697a0129c88e01c1d5ce6a736d60bc2e1d2b2fd3f2e1
Contents?: true
Size: 1.89 KB
Versions: 3
Compression:
Stored size: 1.89 KB
Contents
require 'escape' namespace :sunspot do namespace :solr do desc 'Start the Solr instance' task :start => :environment do if RUBY_PLATFORM =~ /w(in)?32$/ abort('This command does not work on Windows. Please use rake sunspot:solr:run to run Solr in the foreground.') end data_path = File.join(::Rails.root, 'solr', 'data', ::Rails.env) pid_path = File.join(::Rails.root, 'solr', 'pids', ::Rails.env) solr_home = if %w(solrconfig schema).all? { |file| File.exist?(File.join(::Rails.root, 'solr', 'conf', "#{file}.xml")) } File.join(::Rails.root, 'solr') end [data_path, pid_path].each { |path| FileUtils.mkdir_p(path) } port = Sunspot::Rails.configuration.port FileUtils.cd(File.join(pid_path)) do command = ['sunspot-solr', 'start', '-p', port.to_s, '-d', data_path] if solr_home command << '-s' << solr_home end system(Escape.shell_command(command)) end end desc 'Run the Solr instance in the foreground' task :run => :environment do data_path = File.join(::Rails.root, 'solr', 'data', ::Rails.env) solr_home = if %w(solrconfig schema).all? { |file| File.exist?(File.join(::Rails.root, 'solr', 'conf', "#{file}.xml")) } File.join(::Rails.root, 'solr') end FileUtils.mkdir_p(data_path) port = Sunspot::Rails.configuration.port command = ['sunspot-solr', 'run', '-p', port.to_s, '-d', data_path] if RUBY_PLATFORM =~ /w(in)?32$/ command.first << '.bat' end if solr_home command << '-s' << solr_home end exec(Escape.shell_command(command)) end desc 'Stop the Solr instance' task :stop => :environment do FileUtils.cd(File.join(::Rails.root, 'solr', 'pids', ::Rails.env)) do system(Escape.shell_command(['sunspot-solr', 'stop'])) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sunspot_rails-0.10.9 | lib/sunspot/rails/tasks.rb |
sunspot_rails-0.10.8 | lib/sunspot/rails/tasks.rb |
sunspot_rails-0.10.7 | lib/sunspot/rails/tasks.rb |