set :domain,      "5.196.71.90"
set :deploy_to,   "/home/deploy/edco-test"
set :app_path,    "app"
set :web_path,    "web"
set :user,        "deploy"
set :use_sudo,    false
set :branch,      "feature/feature_juin_2016"

set :model_manager, "doctrine"
# Or: `propel`

role :web,        domain                         # Your HTTP server, Apache/etc
role :app,        domain, :primary => true       # This may be the same as your `Web` server

set  :keep_releases,  3

default_run_options[:pty] = true


set :use_composer,    true
set :shared_files,    ["app/config/parameters.yml"]
set :shared_children, [app_path + "/logs", web_path + "/uploads", "vendor"]

# Be more verbose by uncommenting the following line
# logger.level = Logger::MAX_LEVEL

set :app_full_path, deploy_to + "/current/" + app_path

namespace :deploy do
 task :start do ; end
 task :stop do ; end

 task :assets do 
    run "cd #{deploy_to}/current && bower install"
    run "php app/console assets:install"
 end

 task :appmigrate do 
    run "php app/console doctrine:migration:migrate --no-interaction"
 end

 task :restart, :roles => :app, :except => { :no_release => true } do
  run "#{sudo} chown -R deploy.www-data ."
  run "#{sudo} chmod -R 0775 "+app_full_path+"/cache"
  run "#{sudo} chmod -R 0775 "+app_full_path+"/logs"
  run "#{sudo} service php5-fpm restart"
  run "#{sudo} service nginx restart"
 end
end

after "deploy", "deploy:assets", "deploy:restart"