ThinkingSphinx on production:无法分配请求的地址

时间:2014-04-06 11:39:26

标签: apache ruby-on-rails-4 passenger thinking-sphinx

我有一个我今天无法解决的问题。它已经发生在我身上至少一次,但我不记得我到底做了什么来修复它。

我使用Capistrano 3在我自己的服务器上部署我的Rails 4应用程序(使用Apache和Passenger并使用Ruby 2.1)。 目前我因为以下错误而无法使用Thinking-Sphinx:

FATAL: bind() failed on my.ip.address : Cannot assign requested address

这个错误很奇怪,因为我可以无误地使用命令index但不能使用rebuild

我现在正在通过ssh直接在服务器上试图解决这个问题。我必须自己开始searchd吗?在重建期间我是否必须停止Apache?

我甚至不知道从哪里开始。

最后一句话:最奇怪的是,它的工作原理是这样,但我无法重启。

我加入了一些配置文件。

配置/初始化/ thinking_sphinx.rb

ThinkingSphinx::ActiveRecord::DatabaseAdapters.default =
    ThinkingSphinx::ActiveRecord::DatabaseAdapters::PostgreSQLAdapter

ThinkingSphinx::SphinxQL.functions! 

配置/ thinking_sphinx.yml

development:
  mysql41 : 9312
  enable_star: true
  min_prefix_len: 3
  utf8: true

preprod:
  address: "my.domain.com"
  port: 9312
  enable_star: true
  min_prefix_len: 3

配置/ deploy.rb

execute "cd #{fetch(:deploy_to)}/current/ && RAILS_ENV=#{fetch(:environment)} bundle exec rake ts:rebuild", raise_on_non_zero_exit: false
execute "cd #{fetch(:deploy_to)}/current/ && RAILS_ENV=#{fetch(:environment)} bundle exec rake ts:index", raise_on_non_zero_exit: false

日志/ preprod.searchd.log

[Sun Apr  6 15:16:07.185 2014] [ 4647] Child process 4648 has been forked
[Sun Apr  6 15:16:07.191 2014] [ 4648] listening on 82.227.207.7:9312
[Sun Apr  6 15:16:07.191 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:10.194 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:13.196 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:16.199 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:19.202 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:22.205 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:25.208 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:28.212 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:31.215 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:34.218 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:37.221 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:40.224 2014] [ 4648] bind() failed on my.ip.address, retrying...
[Sun Apr  6 15:16:43.228 2014] [ 4648] FATAL: bind() failed on my.ip.address: Cannot assign requested address
[Sun Apr  6 15:16:43.229 2014] [ 4647] Child process 4648 has been finished, exit code 1. Watchdog finishes also. Good bye!

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

我找到了解决方案。错误来自thinking_sphinx.rb文件。 我需要与开发时相同的配置。

preprod:
  mysql41 : 9312
  enable_star: true
  min_prefix_len: 3

最后,问题来自未指定的pid文件路径,我们必须在rake ts:configure之前重新配置sphinx rake ts:rebuild。这完全解决了Capistrano 3的部署问题。

我希望这会对其他人有所帮助。