Created
May 30, 2012 01:28
-
-
Save kyamaguchi/2832268 to your computer and use it in GitHub Desktop.
Capistrano deploy recipes
This file contains hidden or 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
# Deploy tasks for Passenger | |
namespace :deploy do | |
desc "Restarting mod_rails with restart.txt" | |
task :restart, :roles => :app, :except => { :no_release => true } do | |
run "touch #{current_path}/tmp/restart.txt" | |
end | |
[:start, :stop].each do |t| | |
desc "#{t} task is a no-op with mod_rails" | |
task t, :roles => :app do ; end | |
end | |
end | |
default_db_config = <<EOS | |
production: | |
adapter: sqlite3 | |
database: db/data/production.sqlite3 | |
pool: 5 | |
timeout: 5000 | |
EOS | |
set :default_db_config, default_db_config | |
# Handle creation and symlinking of shared/config/database.yml | |
require 'erb' | |
after "deploy:setup", :db | |
after "deploy:finalize_update", "db:symlink" | |
namespace :db do | |
desc "Create a default database.yml in the shared directory." | |
task :default do | |
run "mkdir -p #{shared_path}/config" | |
run "mkdir -p #{shared_path}/data" | |
put ERB.new(default_db_config).result, "#{shared_path}/config/database.yml" | |
end | |
desc "Make symlink for database yaml." | |
task :symlink do | |
run <<-EOF | |
ln -nsf #{shared_path}/config/database.yml #{release_path}/config/database.yml && | |
ln -nsf #{shared_path}/data #{release_path}/db/data | |
EOF | |
end | |
end | |
# Cleanup old releases automatically after deploy | |
after 'deploy:update_code', 'deploy:cleanup' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment