尝试使用capistrano进行部署时出现延迟/收件人错误

时间:2013-06-17 14:28:55

标签: ruby-on-rails capistrano web-deployment

我正在尝试使用capistrano将一些更改部署到现有的ROR应用程序。我正在运行MAC OSX,服务器是Ubuntu 12.0.4。我是ROR和capistrano的新手,所以这里概述了到目前为止我所做的一切。我将我们的github repo克隆到一个本地文件夹,更改了我的代码,更新了github repo,使用:gem install capistrano安装了capistrano,打开了终端,将目录更改为我的ROR应用程序所在的本地文件夹,并尝试{{ 1}}。注意,我没有限制项目,因为项目中存在现有的Deploy和Cap文件。当我运行cap deploy:check时,我得到以下输出:

cap deploy:check

以下是我的deploy.rb文件示例(包含对用户名,服务器名称等的编辑)

/Users/ben/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- delayed/recipes (LoadError)
from /Users/ben/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:152:in `require'
from ./config/deploy.rb:2:in `load'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:93:in `instance_eval'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:93:in `load'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:172:in `load_from_file'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:89:in `load'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:86:in `block in load'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:86:in `each'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:86:in `load'
from Capfile:4:in `load'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:93:in `instance_eval'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:93:in `load'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:172:in `load_from_file'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:89:in `load'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:86:in `block in load'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:86:in `each'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/configuration/loading.rb:86:in `load'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:65:in `block in load_recipes'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:65:in `each'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:65:in `load_recipes'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:31:in `execute!'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:14:in `execute'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/gems/capistrano-2.15.4/bin/cap:4:in `<top (required)>'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/bin/cap:19:in `load'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/bin/cap:19:in `<main>'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@myapp/bin/ruby_noexec_wrapper:14:in `<main>'

以下是封面文件的副本:

require "bundler/capistrano"
require "delayed/recipes"

set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") # Read from local system
require 'rvm/capistrano'

set :rails_env, "production" #added for delayed job

server "myservername", :web, :app, :db, primary: true

set :application, "myapp"
set :user, "deploy"
set :deploy_to, "/home/#{user}/apps/#{application}"
#set :deploy_via, :remote_cache
set :use_sudo, false
set :shared_children, shared_children + %w{public/uploads}

set :scm, "git"
set :scm_passphrase, "mypassword"
set :repository, "git@github.com:myusername/#{application}.git"
set :branch, "master"

default_run_options[:pty] = true
ssh_options[:forward_agent] = true

after "deploy", "deploy:cleanup" # keep only the last 5 releases
after "deploy:stop",    "delayed_job:stop"
after "deploy:start",   "delayed_job:start"
after "deploy:restart", "delayed_job:restart"

namespace :deploy do
  %w[start stop restart].each do |command|
    desc "#{command} unicorn server"
    task command, roles: :app, except: {no_release: true} do
      run "/etc/init.d/unicorn_#{application} #{command}"
    end
  end

  task :setup_config, roles: :app do
    sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
    sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
    run "mkdir -p #{shared_path}/config"
    put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
    puts "Now edit the config files in #{shared_path}."
  end
  after "deploy:setup", "deploy:setup_config"

  task :symlink_config, roles: :app do
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  end
  after "deploy:finalize_update", "deploy:symlink_config"

  desc "Make sure local git is in sync with remote."
  task :check_revision, roles: :web do
    unless `git rev-parse HEAD` == `git rev-parse origin/master`
      puts "WARNING: HEAD is not the same as origin/master"
      puts "Run `git push` to sync changes."
      exit
    end
  end
  before "deploy", "deploy:check_revision"
end

namespace :mailman do
  desc "Mailman::Start"
  task :start, :roles => [:app] do
    run "cd #{current_path};RAILS_ENV=#{rack_env} bundle exec script/mailman_daemon start"
  end

  desc "Mailman::Stop"
  task :stop, :roles => [:app] do
    run "cd #{current_path};RAILS_ENV=#{rack_env} bundle exec script/mailman_daemon stop"
  end

  desc "Mailman::Restart"
  task :restart, :roles => [:app] do
    mailman.stop
    mailman.start
  end
end

我真的很感激这方面的一些帮助。我只需要对生产环境进行一些更改,但我现在还处于停滞状态。希望我已经提供了足够的信息。然而,对于帽子和红宝石来说真的很新,我可能会忽略一些非常明显的东西。提前谢谢!

1 个答案:

答案 0 :(得分:1)

看起来像一个路径问题。你的'延迟/食谱'是什么路径?请记住,require将从 $ LOAD_PATH

加载文件