Sha256: 210132602f14879024564d59aa059e2346e138aedb34835d9565737e408c44bb

Contents?: true

Size: 1.74 KB

Versions: 2

Compression:

Stored size: 1.74 KB

Contents

#!/usr/bin/env ruby

require 'solr_wrapper'
require 'optparse'

options = {}
collection_options = {}
OptionParser.new do |opts|
  opts.banner = "Usage: solr_wrapper [options]"

  opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
    options[:verbose] = v
  end

  opts.on("--version VERSION", "Specify a Solr version to download (default: #{SolrWrapper.default_solr_version})") do |v|
    options[:version] = v
  end

  opts.on("-pPORT", "--port PORT", "Specify the port Solr should run at (default: 8983)") do |p|
    if p == 'random'
      options[:port] = nil
    else
      options[:port] = p
    end
  end

  opts.on("-c", "--cloud", "Run solr in cloud mode") do |c|
    options[:cloud] = c
  end

  opts.on("-iDIR", "--instance_directory DIR", "Install/use solr at the given directory") do |d|
    options[:instance_dir] = d
  end

  opts.on("-lDIR", "--lib_directory DIR", "Grab extra libs from this directory") do |d|
    options[:extra_lib_dir] = d
  end

  opts.on("-nNAME", "--collection_name NAME", "Create a default solr collection with the given name") do |c|
    collection_options[:name] = c
  end

  opts.on("-dDIR", "--collection_config DIR", "Create a default solr collection with the files from the given directory") do |d|
    collection_options[:dir] = d
  end

end.parse!

# default to verbose
options[:verbose] = true if options[:verbose].nil?

instance = SolrWrapper.default_instance(options)
$stderr.print "Starting Solr #{instance.version} on port #{instance.port} ... "
instance.wrap do |conn|
  conn.with_collection(collection_options) do
    $stderr.puts "http://#{instance.host}:#{instance.port}/solr/"
    begin
      while conn.status
        sleep 1
      end
    rescue Interrupt
      $stderr.puts "Solr is shutting down."
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solr_wrapper-0.5.1 exe/solr_wrapper
solr_wrapper-0.5.0 exe/solr_wrapper