本文介绍了SocketError(getaddrinfo:名称或服务未知)-Sunspot/Solr Rails开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将我的rails 3.0.10应用程序部署到带有Passenger,Capistrano,nginx和MySQL的Ubuntu 10.04服务器时,我遇到了很多麻烦(甚至在apache2中遇到了更多麻烦).在将rake降级到0.8.7之后,它终于可以工作了,但是现在Sunspot/Solr在我的开发环境中不起作用. sunspot_solr服务器正在运行,我能够获取服务器的url,并通过浏览器连接到它.该网址与sunspot.yml中的网址相同.我不知道我所做的事情可能会导致问题.我之前曾在黑子上遇到过相同的问题(在我降低了rake的评级之前).然后,它突然又开始工作了.我不知道为什么……我尝试了两个版本的Sunspot(1.2.1和1.3.0).两者都已经开始工作了,但现在不再工作了.

I have had lots of trouble with deploying my rails 3.0.10 application to Ubuntu 10.04 server with Passenger, Capistrano, nginx and MySQL (and even more trouble with apache2). After downgrading rake to 0.8.7 it's finally working, but now Sunspot/Solr doesn't work in my development environment. The sunspot_solr server is running, and I am able to get the server's url, and connect to it via the browser. The url is the same as in sunspot.yml. I have no idea what I have done that can have caused the problem. I had the same problem with sunspot earlier (before I downgraded rake). Then it suddenly started working again. I don't know why... I have tried two versions of Sunspot (1.2.1 and 1.3.0). Both have been working earlier, but not anymore.

这是我收到的错误消息:

This is the error message I'm getting:

SocketError (getaddrinfo: Name or service not known):
app/models/resource.rb:128:in `text_search'
app/controllers/search_controller.rb:21:in `index'

Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.0ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (161.6ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (168.9ms)

控制器有点混乱,所以我只包括相关部分:

The controller is a bit messy so I just include the relevant part:

@criterion = params[:criterion]
@sort_direction = params[:sort_direction]
if @criterion && @sort_direction
  session["sort_search"] = @criterion + "|" + @sort_direction
elsif session["sort_search"]
  @criterion = session["sort_search"].split("|")[0]
  @sort_direction = session["sort_search"].split("|")[1]
else
  @criterion = "updated_at"
  @sort_direction = "desc"
 end
@search = Resource.text_search(session[:search_params] || "", current_user, @criterion, @sort_direction)
@resources = @search.results

自从控制器工作以来,我没有对其进行任何更改.

I have not changed anything in the controller since it was working.

我的gemfile:

source 'http://rubygems.org'
gem 'rake'
gem 'rails', '3.0.10'
gem 'jquery-rails', '>= 1.0.12'
gem 'sqlite3'
gem 'ancestry'
gem 'carrierwave'
gem 'sunspot_rails', '>= 1.3' #'~> 1.2.1' #
gem 'authlogic'
gem 'will_paginate'
gem 'declarative_authorization'
group :production do
  gem 'mysql'
end
group :development do
  gem 'sunspot_solr'
end
gem 'capistrano'

我的rakefile:

My rakefile:

require File.expand_path('../config/application', __FILE__)
require 'rake'

Skolearkivet::Application.load_tasks

推荐答案

只是一个疯狂的猜测,您是否有可能使用localhost作为主机名?尝试将localhost更改为127.0.0.1

just a wild guess, any chance you are using localhost as the hostname? Try changing localhost to 127.0.0.1

这篇关于SocketError(getaddrinfo:名称或服务未知)-Sunspot/Solr Rails开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 04:11