Acts_as_solr: Starting solr server on windows


I was using acts_as_searchable for one of my project, which uses Hyperestraier in background. Yesterday I decided to use acts_as_solr which uses solr(based on Lucene Java search library). I did all written in its Manual/Readme, but when I issued

to start the solr server, it threw a heart breaking “Bad file descriptor” error, although acts_as_solr was working fine on one of my colleague’s linux machine.

I started digging around this and found that there is an issue in rake task that starts the solr server. Actually the problem was this rake task uses ‘fork’ which is not available on windows, also it only handles ‘ECONNREFUSED’ exception which is actually “Connection Refused” error raised by ruby on linux. But in windown it throws ‘EBADF’ which is “Bad file descriptor” error raised by ruby on windows.

So below is the hack for that:

Just add this to vendor/plugins/acts_as_solr/lib/taks/solr.rake, and start solr server on windows by issuing

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
Deploying rails application with pound as a Balancer
Customizing CruiseControl build for RSpec

Reader Comments

Would be great if you filed a ticket for this issue: http://acts_as_solr.railsfreaks.com/newticket

coool…bro !!!!

Thank you!! This solved our problem in seconds. Really appreciate the work you did.

Thank you! but how can we stop solr ?
Ctrl^C is one way, but I wish to stop from script..

This hack didn’t work for me until I renamed the task from :start_win to :startwin. The ‘_’ seems to be a problem in my rails app.

@takemoto: Stop Solr by calling “rake solr:stop”

Thanks buddy! it worked but I didn’t need Errno::EBADF (i left that part alone)

cheers

I tried to work on windows. but whenever I try to run the rake start_win I got the following error “No connection could be made because the target machine actively refused it. - connect(2)”.
My firewall is turned off, so I wonder what may be the problem?

Ahmed,

Make sure MySQL service is running.

Ahmed,

I had to change Errno::EBADF back to Errno::ECONNREFUSED to make it work on windows. The task tries to send an http request to the server, which isn’t running when you invoke the task, so it catches the excepiton and starts the server. For some reason, the exception being thrown is ECONNREFUSED, not EBADF.

Immad

Thanks for your advice. It works for me.

Thanks to all of you guys. I am pleased to know that it helped.


Akhil

You guys can recommend me on working with rails. click here http://www.workingwithrails.com/recommendation/new/person/2892-akhil-bansal

@Immad

Yes, it worked perfectly after I changed the errorno.

Thx very much guys for your help

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.