0

我在 cap deploy:update 的输出中注意到,它触发了“deploy:assets:precompile”作为 deploy:update_code 的后回调:

triggering after callbacks for `deploy:update_code'
  * 2013-05-15 11:32:16 executing `deploy:assets:precompile'
    triggering before callbacks for `deploy:assets:precompile'
  * 2013-05-15 11:32:16 executing `deploy:assets:update_asset_mtimes'
  * executing "[ -e /home/johnmerlino/public_html/store.johnmerlino.com/shared/assets/manifest* ] && cat /home/johnmerlino/public_html/store.johnmerlino.com/shared/assets/manifest* || echo"
    servers: ["xxx.xx.xx.xxx"]
    [xxx.xx.xx.xxx] executing command
    command finished in 314ms
  * executing "cd -- /home/johnmerlino/public_html/store.johnmerlino.com/releases/20130515153214 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
    servers: ["xxx.xx.xx.xxx"]
    [xxx.xx.xx.xxx] executing command
 ** [out :: xxx.xx.xx.xxx] rake aborted!
 ** [out :: xxx.xx.xx.xxx] No such file or directory - /home/johnmerlino/public_html/store.johnmerlino.com/releases/20130515153214/config/config.yml
 ** [out :: xxx.xx.xx.xxx

现在的问题是它说最新版本没有“config.yml”文件。

实际上在我的 capistrano 脚本中,该文件是在“deploy:update_code”之后创建的:

after "deploy:update_code", "deploy:symlink_shared_configs"

namespace :deploy do

 desc "Symlink configuration files"
 task :symlink_shared_configs, :roles => [:db,:app] do
   run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
   run "ln -nfs #{shared_path}/config/config.yml #{release_path}/config/config.yml"
 end

 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
end

那么此时不应该创建 config.yml 吗?

4

1 回答 1

0

如果两者都在回调列表中被触发,after deploy:update_code那么它们本质上属于同一个回调组,但调用同一组中的回调的顺序取决于回调注册和执行的实现

如果您需要它们以给定的顺序运行,那么您可以assets:precompile通过稍后移动config.yml文件或提前移动文件来明确更改运行时间,以确保一个在另一个之前。

就目前而言,由于它们都按照after deploy:update_code执行顺序运行,因此可以是:

  ...before...
deploy:update_code
  ...after...                     | after group
  deploy:symlink_shared_configs   | after group
  deploy:assets:precompile        | after group

...或者...

  ...before...
deploy:update_code
  ...after...                     | after group
  deploy:assets:precompile        | after group
  deploy:symlink_shared_configs   | after group

...并且基于您已发布此问题的事实,听起来后一种情况正在发生在您身上。

于 2013-05-15T16:44:48.270 回答