task :opcache_reset do
pref = fetch(:site_url_prefix, '/')
file = %{"<?php if (php_sapi_name() === 'cli') file_get_contents('http://127.0.0.1#{pref}opreset.php'); opcache_reset();"}
on roles :all do
within current_path do
execute :echo, file, '>', 'opreset.php'
execute :php, 'opreset.php', raise_on_non_zero_exit: false
execute :rm, 'opreset.php'
end
end
end
set :application, 'App'
set :repo_url, 'git@github.com:User/Repo.git'
set :linked_dirs, %w{
backups
logs
}
set :deploy_to, "/usr/share/nginx/www"
namespace :php do
task :reload do
on roles :all do
execute :service, 'php5-fpm', :reload
end
end
task :opcache_reset do
on roles :all do
execute :php, '-r', %{"opcache_reset();"}
end
end
end
namespace :composer do
desc "Composer install"
task :install do
on roles :all do
within release_path do
execute :php, 'composer.phar', :install, '--no-dev', '--no-interaction', '--quiet', '--optimize-autoloader'
end
end
end
task :copy_vendors do
on roles :all do
execute "vendorDir=#{current_path}/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir #{release_path}; fi;"
end
end
end
before 'deploy:updated', "composer:copy_vendors"
before 'deploy:updated', "composer:install"
#after :deploy, 'php:opcache_reset'
after :deploy, 'php:reload'