如何设置 Capistrano 配置路径?
Capistrano 的 config
和 tasks
路径可以显式定义,如下所示
Capfile
# default deploy_config_path is 'config/deploy.rb'
set :deploy_config_path, 'cap/deploy.rb'
# default stage_config_path is 'config/deploy'
set :stage_config_path, 'cap/stages'
# previous variables MUST be set before 'capistrano/setup'
require 'capistrano/setup'
# default tasks path is `lib/capistrano/tasks/*.rake`
# (note that you can also change the file extensions)
Dir.glob('cap/tasks/*.rb').each { |r| import r }
以下是相应的 Capistrano 配置结构
├── Capfile
└── cap
├── stages
│ ├── production.rb
│ └── staging.rb
├── tasks
│ └── custom_tasks.rb
└── deploy.rb
请注意,如果您希望您的 "deploy_config_path" 为 "capistrano/deploy.rb",则必须提供绝对路径。有关更多解释以及如何在 Ruby 中获取绝对路径的信息,请参阅 此问题。