#!/usr/bin/env ruby using_gems = false begin require 'fileutils' require 'tempfile' require 'tmpdir' require 'optparse' require 'daemons' rescue LoadError => e if using_gems raise(e) else using_gems = true require 'rubygems' retry end end working_directory = FileUtils.pwd solr_install = File.expand_path(File.join(File.dirname(__FILE__), '..', 'solr')) port = '8983' data_dir = File.expand_path(File.join(Dir.tmpdir, 'solr_data')) solr_home = File.join(solr_install, 'solr') pid_dir = working_directory log_file = nil log_level = 'OFF' min_memory = '128m' max_memory = '512m' OptionParser.new do |opts| opts.banner = "Usage: sunspot-solr start [options]" opts.on '-p', '--port=PORT', 'Port on which to run Solr (default 8983)' do |p| port = p end opts.on '-d', '--data-directory=DIRECTORY', 'Solr data directory' do |d| data_dir = File.expand_path(d) end opts.on '-s', '--solr-home=HOME', 'Solr home directory (should contain conf/ directory)' do |s| solr_home = File.expand_path(s) end opts.on '--pid-dir=PID_DIR', 'Directory for pid files' do |pd| pid_dir = File.expand_path(pd) end opts.on '-l', '--log-level=LOG_LEVEL', 'Solr logging level' do |l| log_level = l end opts.on '--log-file=LOG_FILE', 'Path to Solr log file' do |lf| log_file = File.expand_path(lf) end opts.on '--max-memory=MEMORY', 'Specify the maximum size of the memory allocation pool' do |mm| max_memory = mm end opts.on '--min-memory=MEMORY', 'Specify the initial size of the memory allocation pool' do |mm| min_memory = mm end end.parse! options = { :dir_mode => :normal, :dir => pid_dir } def logging_properties( log_file, log_level ) temp_file = Tempfile.new 'logging.properties' temp_file << <