Skip to content

Instantly share code, notes, and snippets.

@cmilfont

cmilfont/gist:450298

Created Jun 23, 2010
Embed
What would you like to do?
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