Sha256: 9e171c80ef963909adb68f029fa1bee776904376efafd2ff48820b216916cb47

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

require 'solr_wrapper'

## These tasks get loaded into the host context when solr_wrapper is required
namespace :solr do
  desc "Load the solr options and solr instance"
  task :environment do
    @solr_instance = SolrWrapper.instance
  end

  desc 'Install a clean version of solr. Replaces the existing copy if there is one.'
  task clean: :environment do
    puts "Installing clean version of solr at #{File.expand_path(@solr_instance.instance_dir)}"
    @solr_instance.remove_instance_dir!
    @solr_instance.extract_and_configure
  end

  desc 'start solr'
  task start: :environment do
    begin
      puts "Starting solr at #{File.expand_path(@solr_instance.instance_dir)} with options #{@solr_instance.options}"
      @solr_instance.start
    rescue => e
      if e.message.include?("Port #{@solr_instance.port} is already being used by another process")
        puts "FAILED. Port #{@solr_instance.port} is already being used."
        puts " Did you already have solr running?"
        puts "  a) YES: Continue as you were. Solr is running."
        puts "  b) NO: Either set SOLR_OPTIONS[:port] to a different value or stop the process that's using port #{@solr_instance.port}."
      else
        raise "Failed to start solr. #{e.class}: #{e.message}"
      end
    end
  end

  desc 'restart solr'
  task restart: :environment do
    puts "Restarting solr"
    @solr_instance.restart
  end

  desc 'stop solr'
  task stop: :environment do
    @solr_instance.stop
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solr_wrapper-0.10.0 lib/solr_wrapper/tasks/solr_wrapper.rake
solr_wrapper-0.9.2 lib/solr_wrapper/tasks/solr_wrapper.rake
solr_wrapper-0.9.1 lib/solr_wrapper/tasks/solr_wrapper.rake
solr_wrapper-0.9.0 lib/solr_wrapper/tasks/solr_wrapper.rake