Created
June 23, 2010 18:08
-
-
Save cmilfont/450298 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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