2

我正在使用Mina (Capistrano 的一种更简单的替代方案)current来部署我的 ruby​​ 网站,并且在更新符号链接后我正在尝试运行一些任务。

到目前为止,这是我的 deploy.rb 文件中的内容:

desc "Deploys the current version to the server."
task :deploy => :environment do
  deploy do
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'

    to :launch do
      invoke :restart
    end
  end
end

desc "Manually restart Thin web server"
task :restart do
  in_directory "#{deploy_to}/current" do
    queue! %[bundle exec thin restart -C "#{thin_yml}"]
  end
end 

我的问题是,当 Mina 遇到问题时to :launchcurrent符号链接尚未更新,因此要么它不存在(如果它是该项目的第一次部署),要么它仍然指向 n-1 版本(因此,服务器使用项目的过时版本)。

:restart因此,一旦新版本被移动到发布目录并且当前版本symlink已经更新,我希望能够调用我的任务。

4

1 回答 1

0

我认为这是Mina的错误。在上下文中in_directory使用时似乎无法正常工作。to一个快速而肮脏的解决方法是@commands[:default] = commands(@to)在块的末尾添加in_directory

desc "Manually restart Thin web server"
task :restart do
  in_directory "#{deploy_to}/current" do
    queue! %[bundle exec thin restart -C "#{thin_yml}"]
    @commands[:default] = commands(@to)
  end
end 
于 2015-06-19T21:26:09.853 回答