Skip to content

Instantly share code, notes, and snippets.

@ihassin
Created December 24, 2013 00:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ihassin/8106917 to your computer and use it in GitHub Desktop.
Save ihassin/8106917 to your computer and use it in GitHub Desktop.
Capistrano 3 script to deploy the app
set :application, '<APP_NAME>'
set :repo_url, "<git@PATH/REPO.git>"
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
set :deploy_to, "/home/deploy/rails/<APP_NAME>"
# set :scm, :git
set :format, :pretty
set :log_level, :debug
set :pty, true
set :user, 'deploy'
set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :keep_releases, 5
namespace :deploy do
desc 'Stop application'
task :stop do
on roles(:app), in: :sequence, wait: 5 do
execute "cd #{current_path} && bundle exec passenger stop -p 8080" rescue nil
end
end
desc 'Start application'
task :start do
on roles(:app), in: :sequence, wait: 5 do
execute "cd #{current_path} && bundle exec passenger start -d -p 8080 -e production --user=deploy"
end
end
desc 'Restart application'
task :restart do
invoke "deploy:stop"
invoke "deploy:start"
end
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
after :finishing, 'deploy:cleanup'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment