Skip to content

Instantly share code, notes, and snippets.

@archfizz
Forked from alexrinass/deploy.rb
Created May 30, 2013 12:59
Show Gist options
  • Save archfizz/5677637 to your computer and use it in GitHub Desktop.
Save archfizz/5677637 to your computer and use it in GitHub Desktop.
require "bundler/capistrano"
set :application, "your_app"
# multistage
set :stages, ["staging", "production"]
set :default_stage, "staging"
require "capistrano/ext/multistage"
# whenever
set :whenever_command, "bundle exec whenever"
set :whenever_environment, defer { stage }
set :whenever_identifier, defer { "#{application}_#{stage}" }
require "whenever/capistrano"
# SCM settings
set :repository, "ssh://example.com/repo.git"
set :scm, :git
set :scm_username, "deploy"
set :scm_verbose, true
set :deploy_via, :remote_cache
set :user, "deploy"
set :use_sudo, false
role :web, "example.com"
role :app, "example.com"
role :db, "example.com", :primary => true
set :deploy_to, defer { "/var/www/apps/#{application}/#{stage}" }
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
after "deploy:restart", "deploy:cleanup"
# deploy/production.rb
set :branch, "master"
set :rails_env, "production"
# deploy/staging.rb
set :branch, "staging"
set :rails_env, "staging"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment