Mina 部署:在“当前”符号链接更新后调用任务



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

到目前为止,这是我的 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 :launch 块时,current符号链接尚未更新,因此它要么不存在(如果它是该项目的第一个部署),要么它仍然指向 n-1 版本(因此,服务器使用项目的过时版本)。

因此,我希望能够在新版本移动到发布目录并更新当前symlink后调用我的:restart任务。

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

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 

最新更新