Sha256: 7cf0f47884a1834bcfb258efa278eb9b78652d4b01b3ebafa08ff568ab69804e

Contents?: true

Size: 1.42 KB

Versions: 17

Compression:

Stored size: 1.42 KB

Contents

#!/usr/bin/env ruby
using_gems = false
begin
  require 'fileutils'
  require 'tmpdir'
  require 'daemons'
  require 'optiflag'
rescue LoadError => e
  if using_gems
    raise(e)
  else
    using_gems = true
    require 'rubygems'
    retry
  end
end

working_directory = FileUtils.pwd
solr_home = File.join(File.dirname(__FILE__), '..', 'solr')

module SolrFlags extend OptiFlagSet
  optional_flag 'p' do
    description 'Port on which to run Solr (default 8983)'
    long_form 'port'
  end

  optional_flag 'd' do
    description 'Solr data directory'
  end

  optional_flag 's' do
    description 'Solr home (should contain conf/ directory)'
  end

  optional_flag 'pd' do
    long_form 'pid-dir'
    description 'Directory for pid files'
  end

  and_process!
end

port     = ARGV.flags.p || '8983'
data_dir = File.expand_path(ARGV.flags.d || File.join(Dir.tmpdir, 'solr_data'))
home     = File.expand_path(ARGV.flags.s) if ARGV.flags.s
pid_dir  = File.expand_path(ARGV.flags.pd || working_directory)

options = { :dir_mode => :normal, :dir => pid_dir }

Daemons.run_proc('sunspot-solr', options) do
  FileUtils.cd(working_directory) do
    FileUtils.cd(solr_home) do
      args = ['java']
      args << "-Djetty.port=#{port}" if port
      args << "-Dsolr.data.dir=#{data_dir}" if data_dir
      args << "-Dsolr.solr.home=#{home}" if home
      args << '-jar' << 'start.jar'
      STDERR.puts(args * ' ')
      Kernel.exec(*args)
    end
  end
end

Version data entries

17 entries across 17 versions & 6 rubygems

Version Path
Chrononaut-sunspot-client-0.9.4 bin/sunspot-solr
UnderpantsGnome-sunspot-0.9.1.1 bin/sunspot-solr
UnderpantsGnome-sunspot-0.9.8.1 bin/sunspot-solr
kristopher-sunspot-0.9.8 bin/sunspot-solr
kuahyeow-sunspot-0.9.7 bin/sunspot-solr
kuahyeow-sunspot-0.9.8 bin/sunspot-solr
outoftime-sunspot-0.9.0 bin/sunspot-solr
outoftime-sunspot-0.9.1 bin/sunspot-solr
outoftime-sunspot-0.9.2 bin/sunspot-solr
outoftime-sunspot-0.9.3 bin/sunspot-solr
outoftime-sunspot-0.9.4 bin/sunspot-solr
outoftime-sunspot-0.9.5 bin/sunspot-solr
outoftime-sunspot-0.9.6 bin/sunspot-solr
outoftime-sunspot-0.9.7 bin/sunspot-solr
outoftime-sunspot-0.9.8 bin/sunspot-solr
sunspot-0.9.8 bin/sunspot-solr
sunspot-0.9.7 bin/sunspot-solr