我有一个简短的多阶段 capistrano 脚本,它指定了一个默认阶段(set :default_stage, :staging
),但我发现当我在命令行上指定另一个阶段(例如cap production deploy
)时,暂存和生产任务都会运行:
$ cap production deploy
triggering load callbacks
* 2013-06-19 06:38:34 executing `staging'
* 2013-06-19 06:38:34 executing `production'
因此,部署过程会在 staging.rb 指定的位置查找 scm,这是一个本地存储库——因此它对于生产服务器不存在,因此我的部署失败。
我可以在我的部署脚本中提供一个默认阶段,但在命令行上指定另一个阶段时不加载它吗?
你可以在这里看到我的部署文件:
部署.rb
set :stages, [:staging, :production]
set :default_stage, :staging
require 'capistrano/ext/multistage'
set :repository, "myrepo"
set :scm, :git
set :scm_user, "deploy"
set :user, "deploy"
set (:deploy_to) {"/var/www/clu2/#{application}/"}
set :use_sudo, false
default_run_options[:pty] = true
生产.rb
set :application, "production"
set :rails_env, 'production'
set :deploy_to, "/var/www/myapp/"
set :branch, 'develop'
role :app, 'trustedquote.com'
role :web, 'trustedquote.com'
role :db, 'trustedquote.com', :primary => true
分期.rb
set :application, "staging"
set :rails_env, 'production'
set :repository, "file:///git/myrepo.git"
set :local_repository, "file://."
set :branch, 'develop'
role :app, 'mylocation'
role :web, 'mylocation'
role :db, 'mylocation', :primary => true