Skip to content

Instantly share code, notes, and snippets.

@DimaD
Created June 10, 2009 16:59
Show Gist options
  • Save DimaD/127349 to your computer and use it in GitHub Desktop.
Save DimaD/127349 to your computer and use it in GitHub Desktop.
namespace :sunspot do
namespace :solr do
desc 'Start the Solr instance'
task :start => :merb_env do
sunspot_solr = Merb.root / 'vendor' / 'sunspot' / 'bin' / 'sunspot-solr'
pid_path = Merb.root / 'tmp' / 'solr' / 'pids'
data_path = Merb.root / 'tmp' / 'solr' / 'data'
pid_path = Merb.root / 'tmp' / 'solr' / 'pids'
solr_home = nil
[data_path, pid_path].each { |path| FileUtils.mkdir_p(path) }
port = Sunspot::Merb.config.port
command = [sunspot_solr, 'start', '--', '-p', port.to_s, '-d', data_path, '--pid-dir', pid_path]
FileUtils.cd(File.join(pid_path)) do
puts
sh command.join(' ')
end
end
desc 'Stop the Solr instance'
task :stop => :merb_env do
sunspot_solr = Merb.root / 'vendor' / 'sunspot' / 'bin' / 'sunspot-solr'
pid_path = Merb.root / 'tmp' / 'solr' / 'pids'
port = Sunspot::Merb.config.port
command = [sunspot_solr, 'stop', '--', '--pid-dir', pid_path]
FileUtils.cd(pid_path) do
puts
sh command.join(' ')
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment