Hel*_*rld 5 git capistrano ruby-on-rails
我有一个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
Run Code Online (Sandbox Code Playgroud)
我的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"
Run Code Online (Sandbox Code Playgroud)
他能够使用capistrano部署其他应用程序,我们正在使用capistrano 2.
似乎您正在尝试使用自定义任务部署到多个阶段,而不是使用多阶段扩展。这样,当您运行时,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"
Run Code Online (Sandbox Code Playgroud)
然后,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'
Run Code Online (Sandbox Code Playgroud)
这样您就可以使用cap prod deploy
(或者cap deploy
如果您更改set :default_stage, "staging"
为set :default_stage, "prod"
)部署到生产环境。
归档时间: |
|
查看次数: |
2150 次 |
最近记录: |