Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Created June 23, 2010 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmilfont/450298 to your computer and use it in GitHub Desktop.
Save cmilfont/450298 to your computer and use it in GitHub Desktop.
require "net/http"
class JojobaSunspot
def start
@started = Time.now
up_sunspot if starting
up
end
def stop
system("sunspot-solr stop --pid-dir=/tmp/pids") unless starting
end
private
def port
Sunspot::Rails::Server.new.port
end
def up_sunspot
system("sunspot-solr start -p 8981 -d /tmp/solr_data_test --pid-dir=/tmp/pids --log-file=/tmp/solr_log_test.log --log-level=INFO")
end
def up
while starting
puts "Sunspot server is starting..."
end
puts "Sunspot server took #{'%.2f' % (Time.now - @started)} sec. to get up and running. Let's Jojoba!"
end
def starting
begin
sleep(1)
request = Net::HTTP.get_response(URI.parse("http://localhost:#{port}/solr/"))
false
rescue Errno::ECONNREFUSED
true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment