Skip to content

Instantly share code, notes, and snippets.

@thisivan
Created September 27, 2010 17:49
Show Gist options
  • Save thisivan/599469 to your computer and use it in GitHub Desktop.
Save thisivan/599469 to your computer and use it in GitHub Desktop.
# RVM bootstrap
$:.unshift(File.expand_path("~/.rvm/lib"))
require 'rvm/capistrano'
set :rvm_ruby_string, '1.8.7'
# main details
set :application, "fctableros"
role :web, "your_web_server_ip_or_domain"
role :app, "your_app_server_ip_or_domain"
role :db, "your_db_server_ip_or_domain", :primary => true
# server details
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
set :deploy_to, "/var/your_app_directory"
set :deploy_via, :remote_cache
set :user, "deploy"
set :use_sudo, false
# repo details
set :scm, :git
set :repository, "[email protected]:user/repo.git"
set :branch, "master"
set :git_enable_submodules, 1
# weep 3 releases only in server
set :keep_releases, 3
# runtime dependencies
depend :remote, :gem, "bundler", ">=1.0.0"
# deployment tasks
namespace :deploy do
task :start, :roles => :app do
run "touch #{current_path}/tmp/restart.txt"
end
task :stop, :roles => :app do
# Do nothing.
end
desc "Restart Application"
task :restart, :roles => :app do
run "touch #{current_path}/tmp/restart.txt"
end
desc "Symlink shared resources on each release"
task :symlink_shared, :roles => :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
end
after 'deploy:update_code', 'deploy:symlink_shared'
# Bundler tasks
namespace :bundler do
desc "Symlink bundled gems on each release"
task :symlink_bundled_gems, :roles => :app do
run "mkdir -p #{shared_path}/bundled_gems"
run "ln -nfs #{shared_path}/bundled_gems #{release_path}/vendor/bundle"
end
desc "Install for production"
task :install, :roles => :app do
run "cd #{release_path} && bundle install"
end
end
after 'deploy:update_code', 'bundler:symlink_bundled_gems'
after 'deploy:update_code', 'bundler:install'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment