Return to Snippet

Revision: 13265
at April 16, 2009 15:21 by nate63179


Initial Code
##
# Deploy recipe
# Nate Miller   08.19.08
#------------------------

# Git config
set :scm, :git
set :repository,    "###"
set :deploy_via,    :remote_cache
set :branch, "master"
set :keep_releases, 4


# Server side config
set :application, "inur058"
set :application_path, "/home/iudevelo/apps"
set :user, "###"
set :password, "#####"
set :runner, "iudevelo"
set :use_sudo, false

set :production_database,'iudevelon_production'
set :production_dbhost, 'localhost'
set :staging_database, 'iudevelo_staging'
set :staging_dbhost, 'localhost'

set :dbuser, '###'
set :dbpass, '###'

default_run_options[:pty] = true
ssh_options[:paranoid] = false


## --------------------------------
#  Deployment environment receipes
## --------------------------------


task :staging do
  role :web, "uiclients.com:2020"
  role :app, "uiclients.com:2020"
  role :db, "uiclients.com:2020", :primary => true
  
  
  set :rails_env, 'staging'
  set :environment_database, defer { staging_database }
  set :environment_dbhost, defer {  staging_dbhost }
  set :remote_path, "#{application_path}/stage"
  set :deploy_to, "#{remote_path}"
end

task :testing do
  role :web, "uiclients.com:2020"
  role :app, "uiclients.com:2020"
  role :db, "uiclients.com:2020", :primary => true
  
  set :rails_env, 'test'
  set :environment_database, defer { staging_database }
  set :environment_dbhost, defer {  staging_dbhost }
  set :remote_path, "#{application_path}/test"
  set :deploy_to, "#{remote_path}"
end

task :production do
  role :web, "uiclients.com:2020"
  role :app, "uiclients.com:2020"
  role :db, "uiclients.com:2020", :primary => true

  set :rails_env, 'production'
  set :environment_database, defer { production_database }
  set :environment_dbhost, defer {  production_dbhost }
  set :remote_path, "#{application_path}/live"
  set :deploy_to, "#{remote_path}"
end

## --------------------------------
#  custom receipes
## --------------------------------

# Event hooks
after "deploy:update_code", "db:symlink" 
after "db:symlink", "deploy:create_upload_symlink"
after "deploy:create_upload_symlink", "deploy:cleanup"

# Deploy namespace modifications
namespace :deploy do
  desc "Restarting Passenger through restart.txt file"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end
  
  # Remove unused start and stop tasks
  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with Passenger"
    task t, :roles => :app do ; end
  end
end

namespace :db do
  desc "Make symlink for database yaml" 
  task :symlink do
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" 
  end
end

Initial URL


Initial Description


Initial Title
Sample multi-environment deployment with capistrano

Initial Tags


Initial Language
Ruby