0

deploy.rb的如下

我不断收到以下错误cap deploy:setup

错误信息var/lib/gems/1.9.1/gems/capistrano-2.15.5 /lib/capistrano/configuration/variables.rb:122:inmethod_missing_with_variables': undefined local variable or method shared_children' for #<Capistrano::Configuration:0x00000000daf048> (NameError) capistrano version capistrano-2.15.5 rails version Rails 4.0.0 ruby​​ versionruby 1.9.3p194 (2012-04-20 revision 35410)

任何帮助都将受到高度评价

   require "rvm/capistrano"
   set :rvm_ruby_string, 'default'
   set :rvm_type, :user
   require "bundler/capistrano"

  set :application, "past" 

  set :ip, "xxx.xxx.xxx.xxx"    
  set :domain,"paste.com"
  set :user, "okli"

   set :scm, :none
   set :repository, "."
  set :deploy_via, :copy

 set :deploy_to, "/home/#{user}/#{domain}" 
   set :use_sudo, false

namespace :deploy do
   task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
   end
 end 

after "deploy:update_code", "deploy:copy_old_sitemap"
namespace :deploy do
  task :copy_old_sitemap do
    run "if [ -e #{previous_release}/public/sitemap.xml.gz ]; then cp #{previous_release}/public/sitemap* #{current_release}/public/; fi"
  end
end

after "deploy", "refresh_sitemaps"
task :refresh_sitemaps do
  run "cd #{latest_release} && RAILS_ENV=#{rails_env} rake sitemap:refresh"
end


set :whenever_identifier, "homeworkly"
set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
after "deploy:create_symlink", "deploy:update_crontab"  

namespace :deploy do  
  desc "Update the crontab file"  
  task :update_crontab, :roles => :db do  
    run "cd #{release_path} && whenever --update-crontab #{application}"  
  end  
end  

task :cleanup, :except => { :no_release => true } do
  count = fetch(:keep_releases, 2).to_i

  rsudo <<-CMD
    all=$(ls -x1 #{releases_path} | sort -n);
    keep=$(ls -x1 #{releases_path} | sort -n | tail -n #{count});
    remove=$(comm -23 <(echo -e "$all") <(echo -e "$keep"));
    for r in $remove; do rm -rf #{releases_path}/$r; done;
  CMD

  run <<-CMD
    rm -rf #{latest_release}/public/images &&
    ln -s #{shared_path}/images #{latest_release}/public/images
  CMD

  run <<-CMD
    rm -rf #{latest_release}/uploads &&
    ln -s #{shared_path}/uploads #{latest_release}/uploads
  CMD
end  

desc "tail production log files" 
task :tail_logs, :roles => :app do
  run "tail -f #{shared_path}/log/production.log" do |channel, stream, data|
    puts  # for an extra line break before the host name
    puts "#{channel[:host]}: #{data}" 
    break if stream == :err    
  end
end

after 'deploy:finalize_update', 'bundle:install'

after "deploy:restart", "deploy:cleanup"
4

1 回答 1

0

你必须shared_children为 Capistrano 设置变量,我不知道为什么这不是自动完成的(这是我的工具,我认为它有效)

尝试简单:

set(:shared_children, [])

如果您没有任何需要在部署之间保留的共享路径(这在 Rails 应用程序中不太可能发生,但可能会发生)

根据记录,Capistrano 2 现在也不受支持,您应该升级到 v3,它更快、更流畅,并且有更好的支持和文档。

于 2013-10-24T10:13:12.983 回答