Created
September 9, 2010 16:45
-
-
Save rochefort/572142 to your computer and use it in GitHub Desktop.
capistrano_sample_thinking_sphinx_deploy.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :application, "<app_name>" | |
set :scm, :git | |
set :repository, "<repository_path>" | |
set :branch, 'master' | |
set :deploy_via, :copy | |
set :deploy_to, "<app_path>/#{application}" | |
set :use_sudo, false | |
set :rails_env, "production" | |
set :user, '<ssh_user>' | |
set :password, '<ssh_pass>' | |
role :web, "<web_server>" | |
role :app, "<app_server>" | |
role :db, "<migration_server>", :primary => true | |
before "deploy:setup", "deploy:create_db_dir" | |
after "deploy:update_code" do | |
deploy.change_executable_bt | |
deploy.symlink_sphinx_indexes | |
thinking_sphinx.configure | |
thinking_sphinx.stop | |
thinking_sphinx.start | |
end | |
namespace :deploy do | |
desc 'Grant of execution authority to the batch programs' | |
task :change_executable_bt, :roles => :app do | |
run "chmod 755 #{release_path}/batch/*sh" | |
end | |
desc 'Create a directory to store the sphinx indexes' | |
task :create_db_dir, :roles => :app do | |
run "mkdir -p #{shared_path}/sphinx" | |
end | |
desc 'Restart passenger' | |
task :restart, :roles => :app do | |
send(:run, "touch #{current_path}/tmp/restart.txt") | |
end | |
desc 'Restart apache' | |
task :start, :roles => :app do | |
send(:sudo , "/etc/init.d/apache2 restart") | |
#send(run_method, "sudo /etc/init.d/apache2 restart") | |
end | |
desc "Link up Sphinx's indexes" | |
task :symlink_sphinx_indexes, :roles => [:app] do | |
# If current_path doesn't work for you, use release_path. | |
run "ln -nfs #{shared_path}/sphinx #{release_path}/db/sphinx" | |
end | |
end | |
namespace :thinking_sphinx do | |
[:start, :stop, :configure, :index, :rebuild].each do |t| | |
task t, :roles => [:app] do | |
run "cd #{release_path}; rake thinking_sphinx:#{t} RAILS_ENV=#{rails_env}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
capistranoでthinking_shinxを扱う方法 - うんたらかんたら日記
http://d.hatena.ne.jp/rochefort/20100910/p1