Sha256: 93859413367806f7c21f48c6acf8dadc50ac28ab1b22afa4658e75a0a17847ff

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

require 'escape'

namespace :sunspot do
  namespace :solr do
    desc 'Start the Solr instance'
    task :start => :environment do
      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 '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

9 entries across 9 versions & 2 rubygems

Version Path
outoftime-sunspot_rails-0.10.0 lib/sunspot/rails/tasks.rb
outoftime-sunspot_rails-0.10.1 lib/sunspot/rails/tasks.rb
outoftime-sunspot_rails-0.10.2 lib/sunspot/rails/tasks.rb
outoftime-sunspot_rails-0.9.10 lib/sunspot/rails/tasks.rb
outoftime-sunspot_rails-0.9.11 lib/sunspot/rails/tasks.rb
outoftime-sunspot_rails-0.9.12 lib/sunspot/rails/tasks.rb
outoftime-sunspot_rails-0.9.9 lib/sunspot/rails/tasks.rb
pallan-sunspot_rails-0.9.10 lib/sunspot/rails/tasks.rb
pallan-sunspot_rails-0.9.12 lib/sunspot/rails/tasks.rb