Capistrano and ferret

Problem:

In my project, the /index directory, used by ferret, is not in the svn
repository, for obvious reasons.

Every time I deploy, /index is gone, and the first user to run a search
on the new deployment has a very… long… wait… ahead of them while
the app re-indexes every searchable object in the db.

Solutions?

  1. migrate the index directory over from the previous deployment.
  2. somehow, get ferret to reindex during deployment:
  • either by some magic method I don’t know about, calling
    “/browse/all” on my app, or some such.

What I want to know is… How can I solve this problem with Capistrano.
(Surely it’s been dealt with dozens or hundreds of times before.)

Hello Robert,

In my project, the /index directory, used by ferret, is not in the svn
repository, for obvious reasons.

I have this very same setup.

Solutions?

  1. migrate the index directory over from the previous deployment.

This is the cleanest solution IMHO. Your second approach isn’t
realistic when you’ll have millions of records to index! :wink: First, you
should create an ‘index’ directory in the shared path. Then, add this
to your deploy.rb:

namespace :deploy do
task :before_symlink do
run “ln -fs #{shared_path}/index #{release_path}/index”
end
end

(I know, this the old callbacks syntax with Cap 2, I was experencing
problems with the new syntax and haven’t retried since then. I’ll have
to.)

Hope this helps,

Philippe

Thanks so much for your guidance.

Philippe J. wrote:

Your second approach isn’t
realistic when you’ll have millions of records to index!

I’ll need to re-index anytime a model changes in a ferret-relevant way,
won’t I?

If so, should that be part of the migration process? (add_column and
then reindex every object of that type?)

namespace :deploy do
task :before_symlink do
run “ln -fs #{shared_path}/index #{release_path}/index”
end
end

(I know, this the old callbacks syntax with Cap 2, I was experencing
problems with the new syntax and haven’t retried since then. I’ll have
to.)

Here is how to do that with the new style of callbacks in Cap 2

task :symlink_index do
run “ln -fs #{shared_path}/index #{release_path}/index”
end

before ‘deploy:symlink’, :symlink_index