I use Capistrano to deploy to a server running Nginx. I am facing some issues with APC and I need to restart PHP-FPM after Capistrano has completed the deployment. The question itself is described here , but, like this author, I do not want to remove SSH and restart PHP-FPM remotely from the command line. I would like Capistrano to do this as a deployment hook.
The essence of using deploy.rb is below:
set :application, "deploytest"
set :repository, "git@bitbucket.org:gitaccount/git-repo.git"
set :scm, :git
set :deploy_via, :remote_cache
set :app_webroot, "/public"
default_run_options[:pty] = true
desc "Execute Capistrano tasks against Production server."
task :prod do
role :web, "123.45.67.89"
role :app, "123.45.67.89"
set :env, "prod"
set :domain, "deploy-domain.com"
set :deploy_to, "/var/www/vhosts/#{domain}/site"
set :branch, "master"
end
And I can click using the command;
bundle exec cap prod deploy
It works great. Boy, I struggled to get this command to automatically run another team after deployment is complete.
What I tried
It summarizes the main approaches;
Creating a new namespace for my task
namespace :mcnab do
desc "Running hook post deploy"
task :fpmreload do
execute "service php-fpm reload"
end
end
after "deploy:create_symlink", "mcnab:fpmreload"
"deploy" hook
after "deploy:create_symlink", "deploy:fpmreload"
task :fpmreload do
role :web, "178.62.13.10"
role :app, "178.62.13.10"
on roles(:all) do
execute "service php-fpm reload"
end
end
task :fpmreload do
on "user@123.45.67.89" do
execute "service php-fpm reload"
end
end
"run"
task :fpmreload do
on "user@123.45.67.89" do
run "service php-fpm reload"
end
end
Hrrmph, . , . deploy.rb , , , .