我如何部署而不是 symlink/restart 使用 Capistrano 3?

How can I deploy but not symlink/restart using Capistrano 3?

Capistrano v2 有两个有用的任务:cap deploy:update_code 将完全部署到新的 releases/ 目录,但不会更改 current 符号链接或 start/restart 服务器(因此服务器保持 运行 当前版本而不会中断)。 cap deploy:update 做了同样的事情并更改了 current 符号链接,但没有 start/restart 服务器。这些对于解决问题很有用,例如在进行真正的部署之前进行资产编译。

那两个 "update" 任务在 Capistrano v3 中消失了。是否有一种等效的方法可以在不更改 current 符号链接或重新启动服务器的情况下进行完整部署?

自定义任务列表应该这样做:

task :deploy_without_symlink do
  set(:deploying, true)
  %w{ starting started
      updating updated }.each do |task|
    invoke "deploy:#{task}"
  end
end

您可以在此处查看代码:https://github.com/capistrano/capistrano/blob/master/lib/capistrano/tasks/framework.rake#L58 to see what deploy triggers. And the Publishing task per https://github.com/capistrano/capistrano/blob/master/lib/capistrano/tasks/deploy.rake#L38 是更改符号链接的内容。因此,通过在之后省略所有内容,您将获得所需的内容。