Skip to content

Instantly share code, notes, and snippets.

@nextofsearch
Created September 9, 2013 15:20
Show Gist options
  • Save nextofsearch/6497091 to your computer and use it in GitHub Desktop.
Save nextofsearch/6497091 to your computer and use it in GitHub Desktop.
deploy.rb for capistrano
require 'bundler/capistrano'
require 'capistrano-unicorn'
set :stages, %w(production staging)
set :default_stage, "staging"
require 'capistrano/ext/multistage'
# set :env, fetch(:env, "production")
set :application, "tp"
set :user, "deployer"
set :group, "admin"
set :use_sudo, false
default_run_options[:pty] = true
default_run_options[:shell] = '/bin/bash --login'
ssh_options[:auth_methods] = ["publickey"]
ssh_options[:forward_agent] = true
set :scm, :git
set :repository, "https://nextofsearch:[email protected]/git/adfresca/tp-dev-fresca.git"
set :git_enable_submodules, true
set :bundle_flags, ''
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :keep_releases, 5
after "deploy:update", "deploy:cleanup"
set :unicorn_pid, "#{deploy_to}/shared/pids/unicorn.pid"
set :unicorn_config_path, "#{deploy_to}/shared/config"
namespace :deploy do
namespace :rollback do
desc "Moves the repo back to the previous version of HEAD"
task :repo, :except => { :no_release => true } do
set :branch, "HEAD@{1}"
deploy.default
end
desc "Rewrite reflog so HEAD@{1} will continue to point to at the next previous release."
task :cleanup, :except => { :no_release => true } do
run "cd #{current_path}; git reflog delete --rewrite HEAD@{1}; git reflog delete --rewrite HEAD@{1}"
end
desc "Rolls back to the previously deployed version."
task :default do
rollback.repo
rollback.cleanup
end
end
end
after 'deploy:restart', 'unicorn:restart' # app preloaded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment