Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge remote branch 'evrone/master'

  • Loading branch information...
commit 91506c2584aea645c5475d19cfd8f3acb613cba4 2 parents 7a31150 + 1b0578d
Pat Allan pat authored

Showing 1 changed file with 19 additions and 13 deletions. Show diff stats Hide diff stats

  1. +19 13 ts/en/deployment.textile
32 ts/en/deployment.textile
Source Rendered
@@ -37,28 +37,26 @@ Deploying via Capistrano is simplified by the included recipe file that comes wi
37 37 The first step is to include the recipe in order to define the necessary tasks for us:
38 38
39 39 {%highlight ruby%}
40   -# If you're using Thinking Sphinx as a gem:
  40 +# If you're using Thinking Sphinx as a gem (Rails 3 way):
41 41 require 'thinking_sphinx/deploy/capistrano'
42 42 # If you're using Thinking Sphinx as a plugin:
43 43 require 'vendor/plugins/thinking-sphinx/recipes/thinking_sphinx'
44 44 {%endhighlight%}
45 45
46   -Now we can define our callbacks in order to make sure that Sphinx is properly configured, indexed, and started on each deploy:
  46 +Now we can define our callbacks at the and of @deploy.rb@ in order to make sure that Sphinx is properly configured, indexed, and started on each deploy:
47 47
48 48 {%highlight ruby%}
49   -task :before_update_code, :roles => [:app] do
50   - thinking_sphinx.stop
  49 +before 'deploy:update_code', 'thinking_sphinx:stop'
  50 +after 'deploy:update_code', 'thinking_sphinx:start'
  51 +
  52 +namespace :sphinx do
  53 + desc "Symlink Sphinx indexes"
  54 + task :symlink_indexes, :roles => [:app] do
  55 + run "ln -nfs #{shared_path}/db/sphinx #{release_path}/db/sphinx"
  56 + end
51 57 end
52 58
53   -task :symlink_sphinx_indexes, :roles => [:app] do
54   - run "ln -nfs #{shared_path}/db/sphinx #{release_path}/db/sphinx"
55   -end
56   -
57   -task :after_update_code, :roles => [:app] do
58   - symlink_sphinx_indexes
59   - thinking_sphinx.configure
60   - thinking_sphinx.start
61   -end
  59 +after 'deploy:finalize_update', 'sphinx:symlink_indexes'
62 60 {%endhighlight%}
63 61
64 62 The above makes sure we stop the Sphinx @searchd@ search daemon before we update the code. After the code is updated, we reconfigure Sphinx and then restart. We'll setup a @cron@ job next to keep the indexes up-to-date.
@@ -73,3 +71,11 @@ In your @/etc/crontab@ file, add the following line to the bottom:
73 71 {%highlight bash%}
74 72 0 * * * * deploy cd /path/to/app/current && /usr/local/bin/rake thinking_sphinx:index RAILS_ENV=production
75 73 {%endhighlight%}
  74 +
  75 +Also, you can use the "whenever":https://github.com/javan/whenever gem to control your Cron tasks from the Rails app. The same job for @whenever@ in @config/schedule.rb@ looks like this:
  76 +
  77 +{%highlight ruby%}
  78 +every 2.minutes do
  79 + rake "thinking_sphinx:index"
  80 +end
  81 +{%endhighlight%}

0 comments on commit 91506c2

Please sign in to comment.
Something went wrong with that request. Please try again.