gpt4 book ai didi

ruby-on-rails - 在 Capistrano 配方中将 "before"和 "after"放在哪里?

转载 作者:行者123 更新时间:2023-12-02 07:00:15 25 4
gpt4 key购买 nike

愚蠢的问题,但我们有一个损坏的 Capistrano 配方,我想验证一下我们没有错误地使用 afterbefore

这些之前和之后的任务属于 :deploy 命名空间 block 内还是外部?我看到了 here 的例子.

这是有问题的deploy.rb的摘录:

namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end

# copy database.yml into project
task :copy_database_config do
production_db_config = "/Library/RoRconfig/#{application}.yml"
run "cp #{production_db_config} #{current_release}/config/database.yml"
`puts "replaced database.yml with live copy"`
end

task :pipeline_precompile do
run "cd #{release_path}; RAILS_ENV=production rake assets:precompile"
end

after "deploy:update_code", "deploy:pipeline_precompile" ### <---
before "deploy:finalize_update", "deploy:copy_database_config" ### <---
end

最佳答案

我使用的设置类似于:

after :deploy, "deploy:update_code", "deploy:pipeline_precompile"
before :deploy, "deploy:finalize_update", "deploy:copy_database_config"

namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end

# copy database.yml into project
task :copy_database_config do
production_db_config = "/Library/RoRconfig/#{application}.yml"
run "cp #{production_db_config} #{current_release}/config/database.yml"
`puts "replaced database.yml with live copy"`
end

task :pipeline_precompile do
run "cd #{release_path}; RAILS_ENV=production rake assets:precompile"
end
end

关于ruby-on-rails - 在 Capistrano 配方中将 "before"和 "after"放在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6985482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com