set :stages, %w(staging production)
set :default_stage, "staging"
require 'capistrano/ext/multistage'

set :application, "pottsauction.com"

set :scm, :git
set :repository,  "git@github.com:jgilstrap/pottsauction.com.git"
set :branch, "master"
set :deploy_via, :remote_cache
set :scm_verbose, true

set :user, 'deploy'
set :use_sudo, false
ssh_options[:forward_agent] = true
ssh_options[:port] = 6500

role :app, "www2.pottsauction.com"
role :web, "www2.pottsauction.com"
role :db,  "www2.pottsauction.com", :primary => true

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

  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with passenger"
    task t, :roles => :app do ; end
  end
end

namespace(:custom) do
  task :symlink, :roles => :app do
    run "ln -nfs #{shared_path}/system/image #{release_path}/public/image"
    run "ln -nfs #{shared_path}/system/item #{release_path}/public/item"
  end
end

after "deploy:symlink","custom:symlink"
after "deploy", "deploy:cleanup"