Created
December 14, 2010 11:23
-
-
Save antonversal/740285 to your computer and use it in GitHub Desktop.
Capistrano Recipes whith sphinx
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 :stages, %w(staging production beta) | |
set :default_stage, "staging" | |
require 'capistrano/ext/multistage' | |
# Ok, capistrano_recipes totally breaks not only multistage... | |
# require 'capistrano_recipes' | |
require 'capistrano_colors' | |
require 'bundler/capistrano' | |
require 'thinking_sphinx/deploy/capistrano' | |
require 'config/boot' | |
require 'hoptoad_notifier/capistrano' | |
set :shared_children, %w( config bundle tmp log system sphinx) | |
set :scm, :git | |
set :git_enable_submodules, true | |
set :deploy_via, :remote_cache | |
set :scm_verbose, true | |
set :repository, "[email protected]:l8/zn_new.git" | |
set :branch, "master" | |
set :run_options, { :pty => true } | |
set :ssh_options, { :forward_agent => true } | |
set :use_sudo, false | |
set :bundle_flags, "--deployment" | |
set :bundle_without, [:development, :test, :cucumber, :autotest] | |
on :start do | |
`ssh-add` | |
end | |
set :normal_symlinks, %w( | |
config/newrelic.yml | |
config/database.yml | |
config/unicorn.conf.rb | |
) | |
normal_symlinks << "config/newrelic.yml" unless fetch(:skip_newrelic, true) | |
set :weird_symlinks, { | |
'bundle' => 'vendor/bundle', | |
'tmp' => 'tmp' | |
} | |
after "deploy:setup", "deploy:config_setup" | |
after "deploy:finalize_update", "deploy:app_symlinks" | |
before 'deploy:symlink', 'assets:package' | |
before 'deploy:update_code', 'sphinx:before_update_code' | |
after 'deploy:update_code', 'sphinx:after_update_code' | |
after 'deploy:update_code', 'sphinx:symlink_sphinx_indexes' | |
namespace :deploy do | |
task :default do | |
update | |
migrate | |
restart | |
cleanup | |
end | |
desc "Start unicorn" | |
task :start, :roles => :app do | |
run "cd #{current_path} && rake app:unicorn:start" if fetch(:web_server, nil) == :unicorn | |
end | |
desc "Stop unicorn" | |
task :stop, :roles => :app do | |
run "cd #{current_path} && rake app:unicorn:stop" if fetch(:web_server, nil) == :unicorn | |
end | |
desc "Restart unicorn" | |
task :restart, :roles => :app do | |
# run "cd #{current_path} && rake app:unicorn:restart" | |
case fetch(:web_server, nil) | |
when :unicorn | |
stop | |
start | |
when :passenger | |
run "touch #{release_path}/tmp/restart.txt" | |
end | |
end | |
task :app_symlinks do | |
normal_symlinks.map do |path| | |
run "rm -rf #{release_path}/#{path} && ln -nfs #{shared_path}/#{path} #{release_path}/#{path}" | |
end | |
weird_symlinks.map do |from, to| | |
run "rm -rf #{release_path}/#{to} && ln -s #{shared_path}/#{from} #{release_path}/#{to}" | |
end | |
end | |
desc "Copy *.example.yml to *.yml" | |
task :config_setup do | |
normal_symlinks.map do |path| | |
top.upload path, "#{shared_path}/#{path}" | |
end | |
end | |
task :seed do | |
run "cd #{current_path}; rake RAILS_ENV=#{variables[:rails_env]} db:seed" | |
end | |
end | |
namespace :sphinx do | |
task :before_update_code, :roles => [:app] do | |
thinking_sphinx.stop | |
end | |
task :after_update_code, :roles => [:app] do | |
symlink_sphinx_indexes | |
thinking_sphinx.configure | |
thinking_sphinx.start | |
end | |
task :symlink_sphinx_indexes, :roles => [:app] do | |
run "ln -nfs #{shared_path}/db/sphinx #{release_path}/db/sphinx" | |
end | |
end | |
namespace :assets do | |
desc 'Update package javascripts & stylesheets' | |
task :package, :roles => :app do | |
run "cd #{release_path} && RAILS_ENV=#{rails_env} rake assets:package_stylesheets" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment