【问题标题】:Mina deployment : invoke task once `current` symlink is updatedMina 部署:一旦“当前”符号链接更新就调用任务
【发布时间】:2013-11-07 12:42:55
【问题描述】:

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

到目前为止,这是我的 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 任务。

【问题讨论】:

  • 是否可以调用queue :'restart'而不是直接调用它?
  • 其实不行,queue 命令只允许运行 bash 命令。如果我是正确的,您的意思是排队 :restart 任务而不是立即运行它。实际上,根据我对mina deploy --verbose 所做的测试,似乎在to :launch do 块之后运行了一些东西,我认为这就是我需要的。
  • 我遇到了同样的问题。找到解决方案了吗?
  • 我不再孤单了,耶!不幸的是,到目前为止没有找到解决方案(我必须承认我已经停止研究它)。目前,我在部署后手动使用我的mina restart 任务。我猜这并不完美,但总比没有好。
  • 自从我开始使用 Mina 时就遇到了同样的问题。我会加一个赏金,想要修复。

标签: ruby deployment web-deployment mina


【解决方案1】:

我认为这是 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 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 2014-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-09
    • 2016-01-09
    相关资源
    最近更新 更多