我发现当我尝试运行其Rake任务时,Thinking Sphinx有时会出错。有时候任务工作正常,有时候会出现类似下面的错误。
我以普通用户身份运行任务,而不是root用户。不使用sudo。
在下面的示例中,在Rake任务失败后,searchd仍在运行。
我也看到了ts:rebuild
的类似错误。
有没有人见过这个?
我正在使用Sphinx 0.9.9发行版(r2117)
我正在使用Thinking Sphinx 1.4.4而不是最新版本,因为我使用的是Rails 2.3.11。
$ rake ts:stop RAILS_ENV=production
(in /var/www/blog_app/releases/20110425053509)
rake aborted!
execution expired
(See full trace by running task with --trace)
[ethan@apphost current]$ rake ts:stop RAILS_ENV=production --trace
(in /var/www/blog_app/releases/20110425053509)
** Invoke ts:stop (first_time)
** Invoke thinking_sphinx:stop (first_time)
** Invoke thinking_sphinx:app_env (first_time)
** Execute thinking_sphinx:app_env
** Invoke environment (first_time)
** Execute environment
** Execute thinking_sphinx:stop
rake aborted!
execution expired
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/timeout.rb:60
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/thinking-sphinx-1.4.4/lib/thinking_sphinx/tasks.rb:58
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/opt/ruby/bin/rake:19:in `load'
/opt/ruby/bin/rake:19
答案 0 :(得分:11)
我相信当您的搜索守护程序已经运行时会导致此错误。
尝试
ps | grep searchd
如果能给你这样的东西......
73470 ttys002 0:00.03 searchd --pidfile --config /Users/dwickwire/Projects/production/config/development.sphinx.conf
81907 ttys002 0:00.00 grep searchd
然后杀死searchd
sudo kill -9 process_id
在我的情况下,process_id将是73470
然后尝试rake ts:再次重建。
答案 1 :(得分:6)
我试过命令'ps | grep searchd'获取进程ID,但我没有得到它。 然后我尝试命令'pgrep searchd',它给我进程ID。 我杀了那个进程并运行命令'rake ts:rebuild'。有效。
我在博客上发表了关于整个体验here(免责声明:我是作者)。
答案 2 :(得分:3)
在thinking_sphinx 1.4.4中rake ts:stop
上有 5秒超时
如果rake ts:stop
接近或超过5秒,ruby会抛出异常。
在此期间我正在使用thinking_sphinx 1.3.18。 (1.3.18没有超时)。
此外,我已向the github repository提交了一个补丁,并且可以使用sphinx.yml
配置变量stop_timeout
配置超时。
注意:rake ts:rebuild
== rake ts:stop; rake ts:index; rake ts:start
答案 3 :(得分:0)
我想在经过卡皮斯特拉诺部署之后你没有运行rake thinking_sphinx:configure
它会在config/production.sphinx.conf
尝试将pidfile添加到config/sphinx.yml
production:
...
pid_file: "/tmp/searchd.pid"
它将确保找到searchd的pid来杀死
并将以下代码添加到config/deploy.rb
namespace :my_tasks do
task :generate_sphinx_config, :roles => [:web] do
run "cd #{latest_release} && RAILS_ENV=#{rails_env} bundle exec rake thinking_sphinx:configure"
end
end
....
after :deploy, "my_tasks:generate_sphinx_config"
在每个版本文件夹中生成sphinx配置文件
答案 4 :(得分:0)
问题
如果您的searchd崩溃或手动杀死它,则会出现此问题。在Windows上,它不会覆盖您的searchd.<environment>.pid
,因此仍会保存旧的PID并且ThinkingSphinx不会检查任务管理器中的实际运行进程。因此,所有这些命令(rake ts:restart, rake ts:rebuild, ...
)都无法正常工作,rake将始终中止,您会收到错误rake aborted, ... searchd already running
解决方案
删除path-to/your-app/log/searchd.<environment>.pid
。
<environment>
可能是development
或production
,具体取决于您当前的阶段。
希望这个答案对谷歌的人有所帮助。