Sha256: 2805b84cba0d03192ef0181a6588aec95a8a3251e8a4346025dc1df46fe91f75

Contents?: true

Size: 1.86 KB

Versions: 3

Compression:

Stored size: 1.86 KB

Contents

require 'capistrano/novafabrica/helper'
require 'capistrano/novafabrica/database'

configuration = Capistrano::Configuration.respond_to?(:instance) ?
  Capistrano::Configuration.instance(:must_exist) :
  Capistrano.configuration(:must_exist)

configuration.load do

  after "deploy:update_code", "deploy:create_symlinks"
  after "deploy:update_code", "deploy:cleanup"

  # Configuration
  #

  # Multistage
  require 'capistrano/ext/multistage'
  _cset(:default_stage) { 'staging' }

  # User details
  _cset :user,          'deploy'
  # Application details
  _cset(:runner)        { user }
  _cset :use_sudo,      false

  # SCM settings
  _cset :scm,           'git'
  set(:repository)      { "git@github.com:novafabrica/#{app_name}.git" }
  _cset :branch,        'master'
  _cset :deploy_via,    'remote_cache'
  _cset(:symlinks)      { Hash.new }

  # Git settings for Capistrano
  default_run_options[:pty]     = true # needed for git password prompts
  ssh_options[:forward_agent]   = true # use the keys for the person running the cap command to check out the app

  # Deploy tasks for Passenger
  namespace :deploy do

    desc "Restarting mod_rails with restart.txt"
    task :restart, :roles => :app, :except => { :no_release => true } do
      run "touch #{current_path}/tmp/restart.txt"
    end


    desc "Create symlinks from the latest release to the shared directory"
    task :create_symlinks do

      run "ln -nfs #{shared_path}/config/database.yml #{latest_release}/config/database.yml"

      symlinks.each do |type, value|
        directories = value.is_a?(Array) ? value : [value]
        directories.each do |dir|
          run "mkdir -p  #{shared_path}/public/#{type}/#{dir}"
          run "rm -rf #{latest_release}/public/#{type}/#{dir}"
          run "ln -nfs #{shared_path}/public/#{type}/#{dir} #{latest_release}/public/#{type}/#{dir}"
        end
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capistrano-novafabrica-1.0.5 lib/capistrano/novafabrica/base.rb
capistrano-novafabrica-1.0.4 lib/capistrano/novafabrica/base.rb
capistrano-novafabrica-1.0.3 lib/capistrano/novafabrica/base.rb