Skip to content

Instantly share code, notes, and snippets.

@KidkArolis
Created April 1, 2014 12:48
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 KidkArolis/9913278 to your computer and use it in GitHub Desktop.
Save KidkArolis/9913278 to your computer and use it in GitHub Desktop.
cap deploy.rb
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'twitter'
set :repo_url, 'ssh://git@github.com/KidkArolis/twitter.git'
# Ask which branch to deploy
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
set :deploy_to, "/home/ubuntu/#{fetch(:application)}"
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
set :linked_files, %w{config/production.yml}
# Default value for linked_dirs is []
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :linked_dirs, %w{log tmp}
namespace :deploy do
desc 'Upload built assets'
after :updated, :upload_assets do
run_locally do
execute :gulp, 'build'
on roles(:app) do
upload! 'app/public/build', release_path.join('app/public/'), recursive: true
end
execute :rm, '-rf app/public/build'
end
end
desc 'Install npm dependencies'
after :updated, :npm_install do
on roles(:web) do
within release_path do
execute :npm, 'install --production --cache-min 9999'
end
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment