我有一个capistrano部署脚本可以在我的Windows本地计算机上运行,但是mac上的同事正在遇到部署错误。它实际上只是他的笔记本电脑,因为它也适用于其他的Mac,所以我想知道是否有一些需要清除的capistrano缓存?错误是......
* Compressing /var/folders/kv/g4k3rk815sd14948vzf1lhg40000gn/T/20131203013325 to /var/folders/kv/g4k3rk815sd14948vzf1lhg40000gn/T/20131203013325.tar.gz
executing locally: tar czf 20131203013325.tar.gz 20131203013325
command finished in 114ms
*** [deploy:update_code] rolling back
** [deploy:update_code] exception while rolling back: Capistrano::NoMatchingServersError, `deploy:update_code' is only run for servers matching {:except=>{:no_release=>true}}, but no servers matched `deploy:update_code' is only run for servers matching {:except=>{:no_release=>true}}, but no servers matched
我的deploy.rb(重要部分)如下......
set :application, "app"
task :prod do
role :app, "10.1.40.123"
role :web, "10.1.40.123"
role :db, "10.1.40.123", :primary => true
set :user, "root"
set :password, "password"
set :rails_env, "production"
set :use_sudo, false
load 'deploy/assets' # this line runs rake assets precompile
set :os, 'ubuntu'
default_environment["LD_LIBRARY_PATH"] = '/opt/oracle/instantclient_12_1'
end
set :repository, "ssh://gituser@example.com/opt/git/hub/app.git"
set :deploy_to, "/srv/www/#{application}"
set :deploy_via, :copy
set :keep_releases, 5
set :scm, "git"
set :branch, "master"
after 'deploy:update_code', 'deploy:symlink_shared', "deploy:migrate","deploy:restart"
他可以使用capistrano部署其他应用,我们使用的是capistrano 2.
答案 0 :(得分:0)
似乎您尝试使用自定义任务而不是使用multistage extension部署到多个阶段。这样,当您运行cap prod
时,您实际上并未部署,并且在运行cap deploy
时您没有设置角色,这会导致错误。因此,解决方案是将deploy.rb
重写为以下内容:
set :stages, %w(prod staging)
set :default_stage, "staging"
require 'capistrano/ext/multistage'
set :application, "app"
set :repository, "ssh://gituser@example.com/opt/git/hub/app.git"
set :deploy_to, "/srv/www/#{application}"
set :deploy_via, :copy
set :keep_releases, 5
set :scm, "git"
set :branch, "master"
after 'deploy:update_code', 'deploy:symlink_shared', "deploy:migrate","deploy:restart"
然后,在您的config/deploy/prod.rb
中,您应该与您的产品相关设置:
role :app, "10.1.40.123"
role :web, "10.1.40.123"
role :db, "10.1.40.123", :primary => true
set :user, "root"
set :password, "password"
set :rails_env, "production"
set :use_sudo, false
load 'deploy/assets' # this line runs rake assets precompile
set :os, 'ubuntu'
default_environment["LD_LIBRARY_PATH"] = '/opt/oracle/instantclient_12_1'
这样,如果您将cap prod deploy
更改为cap deploy
,您就可以使用set :default_stage, "staging"
(或set :default_stage, "prod"
}部署到制作中。