twingly / capistrano-twingly

:bookmark_tabs: Capistrano tasks used at Twingly

Home Page:https://rubygems.org/gems/capistrano-twingly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include a default deploy.rb

dentarg opened this issue · comments

Could we use capistrano-twingly to set everything defined in a typical deploy.rb? So if you're happy with the defaults you don't have to specify them in your project.

Here's how it looks today (from Livingstone):

require './config/app_name'

set :repo_url, "git@github.com:twingly/#{APP_NAME}.git"

set :chruby_ruby, File.read('.ruby-version').chomp

set :deploy_to, -> { "/home/deploy/#{fetch(:application)}" }

set :procfile_contents, -> {
  "web: chruby-exec #{fetch(:chruby_ruby)} -- bundle exec " <<
  "thin start -S /tmp/#{fetch(:app_name)}.thin-1.sock -e #{fetch(:stage)}"
}

namespace :deploy do
  desc 'Start application'
  task :start do
    invoke 'deploy:export_upstart'
    on roles(:app) do
      sudo :start, fetch(:application)
    end
  end

  desc 'Restart application'
  task :restart do
    invoke 'deploy:export_upstart'
    on roles(:app) do
      execute "sudo restart #{fetch(:application)} || sudo start #{fetch(:application)}"
    end
  end

  desc 'Stop application'
  task :stop do
    on roles(:app) do
      sudo :stop, fetch(:application)
    end
  end

  after :finishing, 'deploy:nginx:generate_config'
  after :finishing, 'deploy:nginx:upload_config'
  after :finishing, 'deploy:nginx:enable_config'
  after :finishing, 'deploy:nginx:reload'

  after :finishing, 'deploy:cleanup'
  after :finishing, 'deploy:push_deploy_tag'

end