Created
March 6, 2012 15:40
-
-
Save mguterl/1986845 to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
| module Sunspot | |
| class BlockingServer < ::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 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment