Skip to content

Instantly share code, notes, and snippets.

@mguterl
Created October 9, 2012 19:17
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 mguterl/3860830 to your computer and use it in GitHub Desktop.
Save mguterl/3860830 to your computer and use it in GitHub Desktop.
require "net/http"
module Blocking
module Sunspot
class Server < ::Sunspot::Rails::Server
def start
@started = Time.now
super
up
rescue ::Sunspot::Server::AlreadyRunningError
# do nothing
end
private
def uri
"http://0.0.0.0:#{port}/solr/"
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."
end
def starting
begin
sleep(1)
request = Net::HTTP.get_response(URI.parse(uri))
false
rescue Errno::ECONNREFUSED
true
end
end
end # Server
end # Sunspot
end # Blocking
Blocking::Sunspot::Server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment