Sha256: 9599fba4ef101d80d3c89a62aeb3ef79aece40e8f942006a6d67d9ffb049b007

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

require 'capistrano'

unless Capistrano::Configuration.respond_to?(:instance)
  abort "G5cap requires Capistrano >= 2."
end

#Load dependencies first
require 'rubygems'
require 'tinder'
require 'new_relic/recipes' #Load recipes

#Load all of our recipes
recipes= File.expand_path(File.join(File.dirname(__FILE__), '..', 'recipes'))
require "#{recipes}/unicorn"
require "#{recipes}/campfire"
require "#{recipes}/campfire"

Capistrano::Configuration.instance(true).load do
  # Taken from the capistrano code.
  def _cset(name, *args, &block)
    unless exists?(name)
      set(name, *args, &block)
    end
  end

  desc 'Set the branch by splitting the tag unless already set'
  task :set_branch do
    unless exists? :branch
      default_tag = `git tag`.split("\n").last
      tag = Capistrano::CLI.ui.ask "(Tag|Branch|Commit) to deploy [#{default_tag}]: "
      tag = default_tag if tag.empty?
      set( :branch, tag )
    end
  end
  
  namespace :deploy do
    #Using unicorn mainly but could be configured for other webservers:
    # add a recipe
    # set app_server and use in place of unicorn namespace ie send(app_server.to_sym).restart
    desc "Restart the Unicorn processes on the app slices."
    task :restart, :roles => :app, :except=>{:app_server=>false} do
      unicorn.deploy
    end

    desc "Start the Unicorn processes on the app slices."
    task :start, :roles => :app, :except=>{:app_server=>false} do
      unicorn.start
    end

    desc "Stop the Unicorn processes on the app slices."
    task :stop, :roles => :app, :except=>{:app_server=>false} do
      unicorn.stop
    end
  end

  #Default New Relic notices to false as only one of our apps uses this service
  _cset(:new_relic, false)
  if new_relic
    before 'newrelic:notice_deployment', 'newrelic:set_revision'
    after 'deploy:update', 'newrelic:notice_deployment'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
g5cap-0.1.0 lib/g5cap.rb