I\'m finding that Thinking Sphinx sometimes errors out when I try to run its Rake tasks. Sometimes the tasks work fine, and sometimes I get errors like the one below.
I\
I guess after deploy by capistrano you didn't run rake thinking_sphinx:configure
it would generate sphinx config file in config/production.sphinx.conf
try add pidfile to config/sphinx.yml
production:
...
pid_file: "/tmp/searchd.pid"
it will make sure to find pid of searchd to kill
and added following code to 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"
to generate sphinx config file in each release folder
I believe this error is caused when you have a search daemon already running.
Try
ps | grep searchd
if that gives you something like this...
73470 ttys002 0:00.03 searchd --pidfile --config /Users/dwickwire/Projects/production/config/development.sphinx.conf
81907 ttys002 0:00.00 grep searchd
then kill the searchd
sudo kill -9 process_id
process_id in my case would be 73470
Then try rake ts:rebuild again.
The Problem
This problem occurs if your searchd crashed or you killed it manually. On Windows it doesn't overwrite your searchd.<environment>.pid
, so still the old PID is saved and ThinkingSphinx doesn't check the real running processes in your taskmanager. So all these commands (rake ts:restart, rake ts:rebuild, ...
) won't work, rake will always abort and you get the error rake aborted, ... searchd already running
The solution
Delete your path-to/your-app/log/searchd.<environment>.pid
.
<environment>
may be development
or production
, depending on your current stage.
Hope this answer will help the googler's.
I tried command 'ps | grep searchd' to get process ID, but I didn't get it. Then I tried command 'pgrep searchd', it gives me process ID. I killed that process and ran command 'rake ts:rebuild'. It worked.
I blogged about the entire experience here (disclaimer: I'm the author).
In thinking_sphinx 1.4.4 there is a 5 second timeout on rake ts:stop
If rake ts:stop
takes close to or longer than 5 seconds, ruby will throw an exception.
I'm using the thinking_sphinx 1.3.18 in the meantime. (there is no timeout on 1.3.18).
Also I have submitted a patch to the github repository and the timeout will be configurable with a sphinx.yml
configuration variable stop_timeout
.
NOTE: rake ts:rebuild
== rake ts:stop; rake ts:index; rake ts:start