部署 capistrano 部署求助

kaka · 2012年04月10日 · 最后由 wxianfeng 回复于 2012年04月10日 · 4198 次阅读

require "bundler/capistrano" bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile 在执行 bundel exec cap deploy 这个任务的时候想加入 rake 的 trace 参数....

set :application, "dom1"
set :user,"root"
set :password,"321654"
set :repository,  "git@github.com:huxinghai1988/capistrano_dom"
set :domain,"192.168.2.27"

default_run_options[:pty] = true 
set :use_sudo,false
set :scm, "git"
set :scm_user,"root"
set :scm_passphrase,"huxinghai"
set :deploy_to,"/var/www/#{application}"
set :branch, "master"
set :rails_env, 'production'

role :web, domain                          
role :app, domain                        
role :db,  domain, :primary => true

set :rvm_path,"/usr/local/rvm"
set :rvm_bin_path,"/usr/local/rvm/bin"
set :rvm_ruby_string,'ruby-1.9.2'

require 'rvm/capistrano'
require 'bundler/capistrano'

before 'deploy:setup' do
    run 'echo insecure > ~/.curlrc', :shell => 'bash -c'
    find_and_execute_task "rvm:install_rvm"
    find_and_execute_task 'rvm:install_ruby'
end

load 'deploy/assets'


--trace 不可以么?

@lihuazhang 因为我是直接部署它就自己执行这个任务了 bundle exec cap deploy

求帮助!

你可以在自己电脑上跑一下 bundle exec rake RAILS_GROUPS=assets assets:precompile 应该会报相同的错

@ywencn 我在服务器上执行不会有问题!就是部署时会出现

   [192.168.2.27] rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.2' -c 'cd /var/www/dom1/releases/20120410051847 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'
** [out :: 192.168.2.27] rake aborted!
** [out :: 192.168.2.27] 
** [out :: 192.168.2.27] File exists - /var/www/dom1/releases/20120410051847/log
** [out :: 192.168.2.27] 
** [out :: 192.168.2.27] Tasks: TOP => environment
** [out :: 192.168.2.27] (See full trace by running task with --trace)


我想 trace,看一下原因

http://stackoverflow.com/questions/7071126/how-can-i-run-rake-with-trace-within-capistrano

The best way I found is: set :rake, "#{rake} --trace" This way you don't overwrite the rake variable. For example if you use bundler this is set before to: "bundle exec rake" and after to: "bundle exec rake --trace"

#7 楼 @ywencn 试了不可以追踪...

终于可以 trace

task :precompile, :roles => :web, :except => { :no_release => true } do
      run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile --trace"
    end

修改到 capistrano 下的 assets.rb 之后上传 git 服务器就可以追踪!

我每次都是先 cap 上去,然后 手动 precompile , 因为有时 precompile 会出错

需要 登录 后方可回复, 如果你还没有账号请 注册新账号