Last active
December 18, 2015 15:19
-
-
Save localhots/5803396 to your computer and use it in GitHub Desktop.
Keep your deploy.rb clean! Move all customs tasks to config/deploy/recipes/. Define triggers only in deploy.rb file.
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 'bundler/capistrano' | |
logger.level = Logger::DEBUG # Logger::IMPORTANT | |
default_run_options[:pty] = true | |
ssh_options[:forward_agent] = true | |
server 'example.com', :web, :app, :db, :sidekiq, primary: true | |
set :application, 'example' | |
set :user, 'www' | |
set :deploy_via, :remote_cache | |
set :use_sudo, false | |
# Multistage configuration | |
set :stages, %w[ production staging ] | |
set :default_stage, 'production' | |
require 'capistrano/ext/multistage' | |
set :deploy_to, "/home/#{user}/example/" | |
set :scm, 'git' | |
set :repository, '[email protected]:example/example.git' | |
# Sidekiq configuration | |
require 'sidekiq/capistrano' | |
set :sidekiq_role, :sidekiq | |
set :sidekiq_pid, "#{current_path}/tmp/pids/sidekiq.pid" | |
set :sidekiq_processes, 4 | |
%w[ deploy_setup_webservers deploy_setup_config deploy_symlink_config ].each do |recipe| | |
load File.expand_path("../deploy/recipes/#{recipe}.rb", __FILE__) | |
end | |
# Setup unicorn init script and nginx | |
after 'deploy:setup', 'deploy:setup_webservers' | |
# Bootstrap *.example.yml files | |
after 'deploy:setup', 'deploy:setup_config' | |
# Symlink config files from shared to current | |
after 'deploy:finalize_update', 'deploy:symlink_config' | |
# Restart Unicorn | |
require 'capistrano-unicorn' | |
after 'deploy:restart', 'unicorn:restart' | |
# Notify NewRelic | |
require 'new_relic/recipes' | |
after 'deploy:restart', 'newrelic:notice_deployment' | |
# Notify Hipchat | |
require 'hipchat/capistrano' | |
set :hipchat_token, 'secret' | |
set :hipchat_room_name, 'secret' | |
# Keep only the last 5 releases | |
after 'deploy', 'deploy:cleanup' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment