McN*_*Nab 4 deployment capistrano capistrano3
我正在使用Capistrano部署到运行Nginx的服务器.我遇到了APC的一些问题,我需要在Capistrano完成部署后重新加载PHP-FPM.这个问题本身在这里概述, 但是就像那个作者我不想在命令行中远程登录和重新加载PHP-FPM一样,我希望Capistrano能够将其作为一个部署后的钩子.
下面使用deploy.rb的本质;
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
Run Code Online (Sandbox Code Playgroud)
我可以推动使用命令;
bundle exec cap prod deploy
Run Code Online (Sandbox Code Playgroud)
效果很好.男孩,我一直在努力让命令在部署完成后自动触发另一个命令.
我尝试过的;
以下是主要方法的摘要;
为我的任务创建新的命名空间
namespace :mcnab do
desc "Running hook post deploy"
task :fpmreload do
execute "service php-fpm reload"
end
end
after "deploy:create_symlink", "mcnab:fpmreload"
Run Code Online (Sandbox Code Playgroud)将这两个任务包装在"deploy"命名空间中,并使用以下命令触发挂钩
after "deploy:create_symlink", "deploy:fpmreload"
Run Code Online (Sandbox Code Playgroud)在新任务中再次明确设置角色
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
Run Code Online (Sandbox Code Playgroud)明确设置用户
task :fpmreload do
on "user@123.45.67.89" do
execute "service php-fpm reload"
end
end
Run Code Online (Sandbox Code Playgroud)使用'run'而不是execute
task :fpmreload do
on "user@123.45.67.89" do
run "service php-fpm reload"
end
end
Run Code Online (Sandbox Code Playgroud)Hrrmph,其上有大约一百万个变种.我现在真的只是猜测,即使有详细的错误报告,错误消息也没有多大帮助.只有一个工作示例的deploy.rb文件与一个运行命令的简单post deploy钩子将是伟大的,但我找不到一个.
这适合我
before :published, :fpm_reload
desc 'Fpm reload'
task :fpm_reload do
on release_roles :all do |host|
execute :service, 'php5-fpm', :reload
end
end
Run Code Online (Sandbox Code Playgroud)
文档:http: //capistranorb.com/documentation/getting-started/flow/
| 归档时间: |
|
| 查看次数: |
1704 次 |
| 最近记录: |