-1

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

/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>'

这是我的 deploy.rb 文件的示例(对用户名、服务器名等进行了编辑)

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

这是 cap 文件的副本:

load 'deploy'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks

我真的很感激这方面的一些帮助。我只需要对生产环境进行一些更改,但我现在有点停滞不前。希望我已经提供了足够的信息。然而,作为 cap 和 ruby​​ 的新手,我可能会忽略一些非常明显的东西。提前致谢!

4

1 回答 1

1

看起来像一个路径问题。您的“延迟/食谱”属于哪条路径?请记住, require 将从$LOAD_PATH加载文件。

于 2013-06-17T16:35:04.603 回答