Re: [ts] Capistrano deployment

11 views
Skip to first unread message
Message has been deleted

Wade Winningham

unread,
Jul 23, 2008, 10:00:17 PM7/23/08
to thinkin...@googlegroups.com
If your production.sphinx.conf file isn't getting created then either
your rake thinking_sphinx:index is generating an error which could
come from not having permission to write the file to the config
directory or something. Do any messages get generated around the
execution of those lines when you deploy?

Something to look for is if TS is not running then the initial stop
command may fail and could prevent the index and start from taking
place. If you check the output of cap deploy carefully it should point
you in the right direction.

Message has been deleted

Pat Allan

unread,
Jul 23, 2008, 10:33:52 PM7/23/08
to thinkin...@googlegroups.com
It's late where I am, so likely I'm missing something :) - but where
is sphinx.restart being called by capistrano?

--
Pat

On 23/07/2008, at 9:48 PM, PJAY79 wrote:

>
> Hi
>
> I have recently made the switch from Ferret to Sphinx due to some
> problems in production mode.
>
> I have now got Thinking_Sphinx working on my Mac development
> environment and on my Ubuntu production server, with delta indexing.
> And it seems to be working great so far!
>
> However, i am having trouble with deployment from Capistrano.
>
> Whenever i run a 'cap deploy', i am forced to manually login to my
> production server and then run these commands in order to have the
> search functionality working again:
>
> rake thinking_sphinx:stop RAILS_ENV=production
> rake thinking_sphinx:index RAILS_ENV=production
> rake thinking_sphinx:start RAILS_ENV=production
>
> I have tried to automate this with Capistrano using the guide below:
>
> http://www.updrift.com/article/deploying-a-rails-app-with-thinking-sphinx
>
> However, when i login to my production server, there is no
> production.sphinx.conf file, and none of the commands have actually
> executed...but i also get no errors on screen when i run 'cap deploy'.
>
> My deploy.rb looks like this:
>
> _______________________________________________
>
> require 'mongrel_cluster/recipes'
>
> set :application, "project"
> set :domain, "mydomain.com.au"
>
> set :deploy_to, "/home/User/public_html/project/"
> set :user, "User"
>
> set :port, 40000
> ssh_options[:keys] = %w(/Users/User/.ssh/id_rsa)
> ssh_options[:paranoid] = false
> default_run_options[:pty] = true
>
> set :deploy_via, :export
>
> set :repository, "http://mysvn.com"
> set :scm_username, "User"
> set(:scm_password) { Capistrano::CLI.password_prompt("Subversion
> password: ") }
>
> set :mongrel_conf, "/home/User/public_html/project/current/config/
> mongrel_cluster.yml"
>
> role :app, "www.mydomain.com.au"
> role :web, "www.mydomain.com.au"
> role :db, "www.mydomain.com.au", :primary => true
>
> set :runner, nil
>
> desc "Reload Nginx"
> task :reload_nginx do
> sudo "/etc/init.d/nginx reload"
> end
>
> namespace :sphinx do
> desc "Re-establish symlinks"
> task :after_symlink do
> run <<-CMD
> rm -fr #{release_path}/db/sphinx &&
> ln -nfs #{shared_path}/db/sphinx #{release_path}/db/sphinx
> CMD
> end
> desc "Stop the sphinx server"
> task :stop_sphinx , :roles => :app do
> run "cd #{current_path} && rake thinking_sphinx:stop
> RAILS_ENV=production"
> end
> desc "Start the sphinx server"
> task :start_sphinx, :roles => :app do
> run "cd #{current_path} && rake thinking_sphinx:index
> RAILS_ENV=production && rake thinking_sphinx:start
> RAILS_ENV=production"
> end
> desc "Restart the sphinx server"
> task :restart_sphinx, :roles => :app do
> stop_sphinx
> start_sphinx
> end
> desc "Restart mongrel"
> task :restart, :roles => :app do
> restart_sphinx
> sudo restart_mongrel
> end
> end
>
> desc "Symlink the database config file from shared directory to
> current release directory."
> task :symlink_database_yml do
> run "ln -nsf #{shared_path}/config/database.yml #{release_path}/
> config/
> database.yml"
> end
>
> desc "Symlink the amazon config file from shared directory to current
> release directory."
> task :symlink_amazon_s3_yml do
> run "ln -nsf #{shared_path}/config/amazon_s3.yml #{release_path}/
> config/amazon_s3.yml"
> end
>
> namespace :deploy do
> namespace :web do
> desc "Serve up a custom maintenance page."
> task :disable, :roles => :web do
> require 'erb'
> on_rollback { run "rm #{shared_path}/system/maintenance.html" }
> reason = ENV['REASON']
> deadline = ENV['UNTIL']
> template = File.read("app/views/layouts/maintenance.html.erb")
> page = ERB.new(template).result(binding)
> put page, "#{shared_path}/system/maintenance.html",
> :mode => 0644
> end
> end
> end
>
> after "deploy:update_code", "symlink_database_yml"
> after "deploy:update_code", "symlink_amazon_s3_yml"
>
> after "deploy", "reload_nginx"
> after "deploy", "deploy:cleanup"
> after "deploy:migrations", "deploy:cleanup"
>
> _______________________________________________
>
> Would anyone be able to help me with this??
>
> Many thanks,
>
> PJ.
>
> >

WadeWinningham

unread,
Jul 23, 2008, 10:35:46 PM7/23/08
to Thinking Sphinx
Sounds like sphinx is already running and I wonder if the database its
looking at is in an older release directory. I didn't notice anything
like this in your deploy script. I keep my sphinx database in the
shared directory and then symlink to it on deploy.
Message has been deleted

Wade Winningham

unread,
Jul 23, 2008, 10:56:48 PM7/23/08
to thinkin...@googlegroups.com
Still, if TS is running for you, it's using a config file and data
files somewhere. Finding out where may be info that would help.


On Wed, Jul 23, 2008 at 9:53 PM, PJAY79 <pjay...@hotmail.com> wrote:
>
> Hi again,
>
> Wade i have that task in there already...
>
> Pat, i also had these tasks:


>
> desc "Restart the sphinx server"
> task :restart_sphinx, :roles => :app do
> stop_sphinx
> start_sphinx
> end
> desc "Restart mongrel"
> task :restart, :roles => :app do
> restart_sphinx
> sudo restart_mongrel
> end
>

> I just copied direct from Wade's blog post...
>
> I am using Rails 2.0.2, and the latest Sphinx 0.9.8 release.
>
> PJ.

Pat Allan

unread,
Jul 23, 2008, 10:59:34 PM7/23/08
to thinkin...@googlegroups.com
Right, but in Wade's post (or more importantly, pastie) they're in the
deploy namespace, not the sphinx namespace.
http://pastie.org/193035

While deploy.restart gets called automatically, sphinx.restart doesn't.

That might be the cause.

--
Pat

On 23/07/2008, at 10:53 PM, PJAY79 wrote:

>
> Hi again,
>
> Wade i have that task in there already...
>
> Pat, i also had these tasks:
>
> desc "Restart the sphinx server"
> task :restart_sphinx, :roles => :app do
> stop_sphinx
> start_sphinx
> end
> desc "Restart mongrel"
> task :restart, :roles => :app do
> restart_sphinx
> sudo restart_mongrel
> end
>
> I just copied direct from Wade's blog post...
>
> I am using Rails 2.0.2, and the latest Sphinx 0.9.8 release.
>
> PJ.
>
> On Jul 24, 12:35 pm, WadeWinningham <wade.winning...@gmail.com> wrote:

Reply all
Reply to author
Forward
Message has been deleted
0 new messages