Skip to content

Instantly share code, notes, and snippets.

@alChaCC
Created March 27, 2014 02:53
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 alChaCC/9799134 to your computer and use it in GitHub Desktop.
Save alChaCC/9799134 to your computer and use it in GitHub Desktop.
config/deploy.rb
set :whenever_command, "bundle exec whenever"
set :assets_role, [:web, :shadow, :asset_syncer, :sidekiqer]
begin
require 'capistrano_colors'
rescue LoadError
puts "`gem install capistrano_colors` to get output more userfriendly."
end
set :rvm_type, :system
require "rvm/capistrano"
require 'capistrano/ext/multistage'
set :stages, %w(production staging)
set :default_stage, "staging"
require 'bundler/capistrano'
require "whenever/capistrano"
set :application, "cool application name"
set :repository, "your@git.location"
set :ssh_options, { :forward_agent => true }
set :scm, :git
set :deploy_via, :copy
set :git_shallow_clone, 1
set :scm_verbose, true
set :use_sudo, false
set :symlink_paths, ['config/database.yml', 'config/application.yml']
# from https://github.com/AF83/capistrano-af83/blob/master/lib/capistrano/af83/deploy/assets.rb
set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb)
namespace :deploy do
desc "Restart passenger process"
task :restart, :roles => [:web], :except => { :no_release => true } do
run "touch #{current_path}/tmp/restart.txt"
end
task :symlink_files do
symlink_paths.each do |path|
run "ln -sf #{shared_path}/#{path} #{release_path}/#{path}"
end
end
namespace :assets do
task :sync, :roles => [:asset_syncer] do # you must set "shadow" server role
run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:sync"
end
end
end
namespace :remote_rake do
desc "Run a task on remote servers, ex: cap staging remote_rake:invoke task=cache:clear"
task :invoke do
run "cd #{deploy_to}/current; RAILS_ENV=#{rails_env} bundle exec rake #{ENV['task']}"
end
end
# cap staging tail_log
task :tail_log, :roles => :app do
run "tail -f -n 100 #{shared_path}/log/#{rails_env}.log"
end
after "deploy:finalize_update", "deploy:symlink_files"
after "deploy", "deploy:cleanup"
after "deploy:assets:precompile", "deploy:assets:sync"
set :sidekiq_cmd, "bundle exec sidekiq"
set :sidekiqctl_cmd, "bundle exec sidekiqctl"
set :sidekiq_role, :sidekiqer
require 'sidekiq/capistrano'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment