Skip to content

Instantly share code, notes, and snippets.

@ucheng
Forked from andrik/gist:3609935
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ucheng/3bdd6819ecd1cc63414a to your computer and use it in GitHub Desktop.
Save ucheng/3bdd6819ecd1cc63414a to your computer and use it in GitHub Desktop.
require 'bundler/capistrano'
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
set :user, "<<your webfaction user>>"
set :domain, "#{user}@<<your domain>>"
set :application, "<<your application>>"
set :repository, "<< your ssh repository link >>"
set :deploy_to, "/home/#{user}/webapps/#{application}"
set :default_stage,"production"
set :assets_path, "#{deploy_to}/shared/assets"
set :verbose_command_log, true
set :use_sudo, false
set :deploy_via, :checkout
set :branch, "master"
set :default_environment, {
'PATH' => "#{deploy_to}/bin:$PATH",
'GEM_HOME' => "#{deploy_to}/gems",
'RAILS_ENV' => "#{default_stage}"
}
set :scm, :git
role :web, "<<hostname for your Webfaction server>>"
role :app, "<<hostname for your Webfaction server>>"
role :db, "<<hostname for your Webfaction server>>", :primary => true
desc "Restart nginx"
task :restart do
run "#{deploy_to}/bin/restart"
end
desc "Start nginx"
task :start do
run "#{deploy_to}/bin/start"
end
desc "Stop nginx"
task :stop do
run "#{deploy_to}/bin/stop"
end
namespace :deploy do
puts "============================================="
puts "SIT BACK AND RELAX WHILE CAPISTRANO ROCKS ON!"
puts "============================================="
desc "Seed database"
task :remakedb do
run "cd #{deploy_to}/current; bundle exec rake db:migrate RAILS_ENV=#{default_stage}"
run "cd #{deploy_to}/current; bundle exec rake db:seed RAILS_ENV=#{default_stage}"
end
desc "Seed database"
task :seed do
run "cd #{deploy_to}/current; bundle exec rake db:seed RAILS_ENV=#{default_stage}"
end
desc "Migrate database"
task :migrate do
run "cd #{deploy_to}/current; bundle exec rake db:migrate RAILS_ENV=#{default_stage}"
end
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
%x{bundle exec rake assets:precompile}
%x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{domain}:#{assets_path}}
%x{bundle exec rake assets:clean}
end
end
end
after "deploy", "assets:precompile"
after "deploy", "deploy:migrate"
after "deploy", "restart"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment