Skip to content

Instantly share code, notes, and snippets.

@raecoo
Created April 21, 2012 01:48
Show Gist options
  • Save raecoo/2433224 to your computer and use it in GitHub Desktop.
Save raecoo/2433224 to your computer and use it in GitHub Desktop.
Capistrano Recipe
require 'bundler/capistrano'
load 'deploy/assets'
set :domain, "example.com"
set :application, "application"
set :user, "deploy"
set :password, "secret"
set :use_sudo, false
set :deploy_to, "/home/#{user}/www/#{application}"
set :shared_path, "#{deploy_to}/shared"
set :repository, "git repo address"
set :scm, "git"
set :branch, "master"
set :keep_releases, 3
set :deploy_via, :remote_cache
set :scm_username, ""
set :scm_password, ""
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
role :web, domain
role :app, domain
role :db, domain, :primary => true
after "deploy:finalize_update", "deploy:symlink_configs"
after 'deploy:symlink_configs', 'deploy:migrate'
namespace :deploy do
desc "Restart Application"
task :restart, :roles => :app do
run "touch #{deploy_to}/#{shared_dir}/tmp/restart.txt"
end
desc "Setup Standard Configuration Links"
task :symlink_configs, :roles => :app do
run "ln -nfs #{shared_path}/database.yml #{release_path}/config/database.yml"
run "rm -rf #{release_path}/tmp"
run "ln -nfs #{shared_path}/tmp #{release_path}/tmp"
end
desc "init database by Seed"
task :seed, :roles => :app do
run "cd #{latest_release} && bundle exec rake db:seed RAILS_ENV=production"
end
end
@raecoo
Copy link
Author

raecoo commented Jul 4, 2012

Don't forget add "require 'rake/dsl_definition'" in Rakefile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment