Created
January 20, 2013 11:25
-
-
Save jakcharlton/4577995 to your computer and use it in GitHub Desktop.
Basic cap script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/https' | |
require 'json' | |
set :stages, %w(production staging) | |
set :default_stage, "staging" | |
require 'capistrano/ext/multistage' | |
require 'bundler/capistrano' | |
default_run_options[:pty] = true | |
set :application, 'porpoise' | |
set :repository, "git@bitbucket.org:fairfax/china-#{application}.git" | |
set :scm, :git | |
set :scm_verbose, true | |
set :deploy_via, :remote_cache # A checked-out copy of the repo that is then updated and copied as necessary. | |
set :bundle_cmd, "/var/lib/gems/1.9.1/bin/bundle" | |
# Use the local user's keys for convenience. (May not be applicable here.) | |
set :ssh_options, { forward_agent: false } | |
set :runner, "updatebot" | |
set :user, "updatebot" | |
set :use_sudo, false | |
ssh_options[:keys] = %w(~/.ssh/updatebot_ssh) | |
ssh_options[:user] = "updatebot" | |
ssh_options[:port] = 22 | |
ssh_options[:forward_agent] = false | |
namespace :deploy do | |
task :full do | |
update_code | |
assets | |
check_env | |
uploads_symlink | |
symlink | |
setup_db | |
restart | |
end | |
task :assets do | |
run "cd #{release_path} && RAILS_ENV=#{rails_env} /var/lib/gems/1.9.1/bin/bundle exec rake assets:precompile" | |
end | |
task :check_env do | |
# Will it float? | |
run "if [ ! -d #{shared_path}/pids ]; then mkdir -p #{shared_path}/pids; fi" | |
end | |
task :uploads_symlink do | |
run "if [ ! -L #{release_path}/public/images ]; then rm -rf #{release_path}/public/images; fi" | |
run "if [ ! -e #{release_path}/public/images ]; then ln -sv #{shared_path}/images #{release_path}/public/images; fi" | |
end | |
task :restart, except: { no_release: true } do | |
run "touch #{release_path}/tmp/restart.txt" | |
end | |
task :setup_db do | |
run "cd #{current_path} && RAILS_ENV=#{rails_env} /var/lib/gems/1.9.1/bin/bundle exec rake db:setup" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment