Skip to content

Instantly share code, notes, and snippets.

@nlevchuk
Created November 29, 2012 09:02
Show Gist options
  • Save nlevchuk/4167713 to your computer and use it in GitHub Desktop.
Save nlevchuk/4167713 to your computer and use it in GitHub Desktop.
config/deploy.rb
require 'bundler/capistrano'
require "rvm/capistrano"
require 'capistrano/ext/multistage'
load 'deploy/assets'
set :rvm_path, '/home/<USERNAME>/.rvm'
set :rvm_bin_path, '/home/<USERNAME>/.rvm/bin'
set :repository, '[email protected]:<GIT_USERNAME>/<REPOSITORY_NAME>.git'
set :scm, :git
set :deploy_via, :remote_cache
set :copy_exclude, ['.git']
set :rvm_ruby_string, 'ruby-1.9.3-p194'
set :use_sudo, false
set :normalize_asset_timestamps, false # For Rails 3.1
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
namespace :deploy do
task :restart do
run "cd #{current_path}; touch tmp/restart.txt"
end
task :sql_symlink do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
end
namespace :unicorn do
task :start do
run "cd #{deploy_to}/current && unicorn_rails -c #{deploy_to}/current/config/unicorn.rb -E #{rails_env} -D"
end
task :stop do
run "kill -s QUIT `cat #{deploy_to}/shared/pids/unicorn.pid`"
end
task :restart do
run "kill -s USR2 `cat #{deploy_to}/shared/pids/unicorn.pid`" # needs if preload_app = true
end
end
before 'deploy:assets:precompile', 'deploy:sql_symlink'
after 'deploy:update', 'unicorn:restart', 'deploy:cleanup'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment