set :user, 'web'

set :application, 'test.lamaisondelarbre.fr' # use your folder app name
set :deploy_to, "/home/#{user}/apps/#{application}/" # the live app will be in the "current" subdir
set :deploy_via, :remote_cache

#set :keep_releases, 1


#use trunk to deploy to production
  set :branch, "master"
  set :rails_env, "production"

#production
  set :domain, 'test.lamaisondelarbre.fr' # your http://publicdomain.com
  role :app, domain
  role :web, domain
  role :db, domain, :primary => true



set :scm, :git
set :repository,  "git@box1.quartz-agence.com:test-mda.git"

set :use_sudo, false
set :ssh_options, {:forward_agent => true}

after "deploy", "deploy:bundle_gems"
after "deploy:bundle_gems", "deploy:make_simlinks"
after "deploy:make_simlinks", "deploy:restart"
after "deploy:restart", "deploy:cleanup"

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
	task :bundle_gems do 
		run "cd #{deploy_to}current && bundle install"
	end
	
	task :make_simlinks do 
		run "rm -rf #{deploy_to}current/db/production.sqlite3"
		run "ln -s #{deploy_to}shared/sqlite3_databases/production.sqlite3 #{deploy_to}current/db/production.sqlite3"
		
		run "rm -rf #{deploy_to}current/private_medias"
		run "ln -s #{deploy_to}shared/medias/private #{deploy_to}current/private_medias"
		
		run "rm -rf #{deploy_to}current/public/public_medias"
		run "ln -s #{deploy_to}shared/medias/public #{deploy_to}current/public/public_medias"
	end
	task :start do ; end
	task :stop do ; end
	task :restart, :roles => :app, :except => { :no_release => true } do
		run "touch #{File.join(current_path,'tmp','restart.txt')}"
	end
end
