Skip to content

Instantly share code, notes, and snippets.

@jesscanady
Created May 8, 2012 17:30
Show Gist options
  • Save jesscanady/2637656 to your computer and use it in GitHub Desktop.
Save jesscanady/2637656 to your computer and use it in GitHub Desktop.
Deploy scripts!
# in config/deploy.rb
set :default_stage, 'staging'
require 'capistrano/ext/multistage'
require 'bundler/capistrano'
set :application, "appname"
set :repository, "ssh://servername/path/to/repository.git"
set :use_sudo, false
default_run_options[:pty] = true
set :scm, :git
after "deploy:update_code", "deploy:secondary_symlink"
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{File.join(current_path,'tmp','restart.txt')}"
end
# link in config files from the shared dir
task :secondary_symlink, :except => { :no_release => true } do
%W{database.yml}.each do |filename|
run "rm -f #{release_path}/config/#{filename}"
run "ln -s #{deploy_to}/shared/config/#{filename} #{release_path}/config/#{filename}"
end
end
end
# in config/deploy/production.rb
# For non-Rails apps:
# set :rack_env, "production"
# set :migrate_env, "RACK_ENV=#{rack_env}"
set :rails_env, "production"
set :deploy_to, "/path/to/production/root/"
server "servername", :app, :web, :db, :primary => true
# in config/deploy/staging.rb
# For non-Rails apps:
# set :rack_env, "staging
# set :migrate_env, "RACK_ENV=#{rack_env}"
set :rails_env, "staging"
set :deploy_to, "/path/to/staging/root/"
# deploys whatever branch you're on right now
set :branch, $1 if `git branch` =~ /\* (\S+)\s/m
server "servername", :app, :web, :db, :primary => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment