gpt4 book ai didi

deployment - 设置 :deploy_to from server config in Capistrano3

转载 作者:行者123 更新时间:2023-12-04 01:06:57 25 4
gpt4 key购买 nike

在我的 Capistrano 3 部署中,我想设置 set :deploy_to, -> { "/srv/www/#{fetch(:application)}"} 所以 :deploy_to 对于部署到的每个服务器都是不同的。

在我的 staging.rb 文件中我有:

server 'dev.myserver.com', user: 'deploy', roles: %w{web app db}, install_path: 'mycustom/path'
server 'dev.myserver2.com', user: 'deploy', roles: %w{web app db}, install_path: 'mycustom/other/path'

我的问题是:是否可以在我的 :deploy_to 中使用我定义的“install_path”?如果可能的话,你会怎么做?

最佳答案

最后,在环顾四周之后,我遇到了一位 Capistrano 开发人员提出的问题,他明确指出它无法完成

引自Github issue :

Not possible, sorry. fetch() (as is documented widely) reads values set by set(), the only reason to use set() and fetch() over regular ruby variables is to provide a consistent API between plugins and extensions, and because set() can take a Proc to be resolved later.

The variables you are setting in the host object via the server() command belong to an individual host, some of them, user, roles, etc have special meanings. For more information see https://github.com/capistrano/sshkit/blob/master/EXAMPLES.md#do-something-different-on-one-host-or-another-depending-on-a-host-property.

If you specifically need to deploy to a different directory on each machine you probably should not be using the built-in tasks (they don't fit your needs), and rather copy the deploy.rake from the Gem into your own project, and modify it as you need. Which in this case might be to not take fetch(:deploy_to), but to read that from a host property.

You could try to do something where before doing anything that relies on calling fetch(:deploy_to), you set() it using the value from host.someproperty but I'm pretty sure that'll break in exciting and interesting ways.

关于deployment - 设置 :deploy_to from server config in Capistrano3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29353019/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com