我的deploy.rb
如下
我一直收到以下错误cap deploy:setup
var/lib/gems/1.9.1/gems/
capistrano-2.15.5 /lib/capistrano/configuration/variables.rb:122:in
method_missing_with_variables'的错误消息:未定义的局部变量或方法shared_children' for #<Capistrano::Configuration:0x00000000daf048> (NameError)
卡皮斯特拉诺版本 capistrano-2.15.5
导轨版本 Rails 4.0.0
红宝石版本 ruby 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"
为 Capistrano 设置变量shared_children
,我不知道为什么没有自动完成(这是我的工具,我认为它有效)
尝试简单:
set(:shared_children, [])
如果您没有任何需要在部署之间保留的共享路径(这在 Rails 应用程序中不太可能,但可能会发生)
为了记录Capistrano 2现在也不受欢迎,您应该升级到v3,它更快,更流畅,并且具有更好的支持和文档。