Skip to content

Instantly share code, notes, and snippets.

@xavismeh
Created May 27, 2016 15:09
Show Gist options
  • Save xavismeh/cc64f14542d04879d4ce5c25c2b1eac8 to your computer and use it in GitHub Desktop.
Save xavismeh/cc64f14542d04879d4ce5c25c2b1eac8 to your computer and use it in GitHub Desktop.
Flush FCGI opcache during capistrano deployment using cachetool
namespace :cachetool do
task :run, :command do |t, args|
args.with_defaults(:command => :list)
on release_roles(fetch(:cachetool_roles)) do
within fetch(:cachetool_working_dir) do
execute :cachetool, args[:command], *args.extras
end
end
end
desc 'Flush the FCGI opcache'
task :flush do
fcgi_socket = fetch(:fcgi_socket)
invoke 'cachetool:run', 'opcache:reset', fcgi_socket ? "--fcgi=#{fcgi_socket}" : ''
end
end
after 'deploy:published', 'cachetool:flush'
after 'deploy:reverted', 'cachetool:flush'
namespace :load do
task :defaults do
set :cachetool_roles, :all
set :cachetool_working_dir, -> { fetch(:release_path) }
set :cachetool_download_url, "http://gordalina.github.io/cachetool/downloads/cachetool.phar"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment