RAILS acts_as_solr
来源:互联网 发布:软件测试论坛 编辑:程序博客网 时间:2024/06/05 15:18
- rake solr:start
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:
- desc 'Starts Solr. on windows . Options accepted: RAILS_ENV=your_env, PORT=XX. Defaults to development if none.'
- task :start_win do
- begin
- n = Net::HTTP.new('localhost', SOLR_PORT)
- n.request_head('/').value
- rescue Net::HTTPServerException #responding
- puts "Port #{SOLR_PORT} in use" and return
- rescue Errno::EBADF #not responding
- Dir.chdir(SOLR_PATH) do
- exec "java -Dsolr.data.dir=solr/data/#{ENV['RAILS_ENV']} -Djetty.port=#{SOLR_PORT} -jar start.jar"
- sleep(5)
- puts "#{ENV['RAILS_ENV']} Solr started sucessfuly on #{SOLR_PORT}, pid: #{pid}."
- end
- end
- end
Just add this to vendor/plugins/acts_as_solr/lib/taks/solr.rake, and start solr server on windows by issuing
- rake solr:start_win
- RAILS acts_as_solr
- Rails
- Rails
- Rails
- rails
- Rails
- rails
- Rails
- Rails
- Rails
- Rails
- Rails
- Rails
- Rails
- Rails
- Rails
- rails
- Rails
- Chapter 8 Visitation: Iterators and Containers
- Chapter 9 Templates. Generic Programming. and STL
- Explorer命令行参数
- 没有心思写文章
- ADO第一次亲密接触 -- ADO开发实践
- RAILS acts_as_solr
- 今天你说"NO"了吗?
- linux下 Oracle自动启动与停止
- 一个简单的端口扫描程序题
- 浮动层代码兼容性
- ubuntu 常见安装软件错误
- Beowulf
- 学会去管理时间
- 如何创建不规则的Windows窗体?