#!/usr/bin/env ruby begin require 'fileutils' require 'tempfile' require 'tmpdir' require 'optparse' require File.join(File.dirname(__FILE__), '..', 'lib', 'sunspot', 'solr', 'server') rescue LoadError => e if require 'rubygems' retry else raise(e) end end server = Sunspot::Solr::Server.new opts = OptionParser.new do |opts| opts.banner = "Usage: sunspot-solr (start|stop|run) [options]" opts.on '-p', '--port=PORT', 'Port on which to run Solr (default 8983)' do |p| server.port = p end opts.on '-b', '--bind-address=address', 'Interface on which to run Solr (default 0.0.0.0)' do |b| server.bind_address = b end opts.on '-s', '--solr-home=HOME', 'Solr home directory (should contain conf/ directory)' do |s| server.solr_home = File.expand_path(s) end opts.on '-j', '--solr-jar=JAR', 'Solr start jar' do |j| server.solr_jar = File.expand_path(j) end opts.on '--pid-dir=PID_DIR', 'Directory for pid files' do |pd| server.pid_dir = File.expand_path(pd) end opts.on '-l', '--log-level=LOG_LEVEL', 'Solr logging level' do |l| server.log_level = l end opts.on '--log-file=LOG_FILE', 'Path to Solr log file' do |lf| server.log_file = File.expand_path(lf) end opts.on '--max-memory=MEMORY', 'Specify the maximum size of the memory allocation pool' do |mm| server.max_memory = mm end opts.on '--min-memory=MEMORY', 'Specify the initial size of the memory allocation pool' do |mm| server.min_memory = mm end end opts.parse! begin case ARGV[0] when 'start' server.start when 'run' server.run when 'stop' server.stop when 'restart' server.stop server.start else abort(opts.help) end rescue Sunspot::Solr::Server::ServerError => e abort(e.message) end