簡體   English   中英

Bundler + RVM + Passenger + Capistrano部署和缺少的寶石

[英]Bundler + RVM + Passenger + Capistrano deployment & missing gems

我得到了上面配置的服務器。

這是我的deploy.rb配方的重要部分:

$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
require 'bundler/capistrano'

set :rvm_ruby_string, 'ruby-1.9.2-p290'
set :rvm_type, :system
set :bundle_flags, "--deployment"

set :default_environment, {
  'PATH' => ENV['PATH'],
  'RAILS_ENV' => ENV['RAILS_ENV']
}

set :stages, %w(staging production)
require 'capistrano/ext/multistage'

按原樣運行cap staging deploy會導致錯誤:

* executing "cd /mnt/data-store/project/releases/shared &&
bundle install --gemfile /mnt/data-store/project/releases/shared/Gemfile
--path /mnt/data-store/project/shared/bundle --deployment --without development test"

** [out :: localhost] The --deployment flag requires a Gemfile.lock.
Please make sure you have checked your Gemfile.lock into version control
before deploying.

... rolling back ...

failed: "env PATH=... RAILS_ENV=staging rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.2-p290' -c 'cd /mnt/data-store/project/releases/shared && bundle install --gemfile /mnt/data-store/project/releases/shared/Gemfile --path /mnt/data-store/project/shared/bundle --deployment --without development test'" on localhost

Gemfile和Gemfile.lock位於源代碼管理中。 我首先在本地運行bundle install以生成.lock文件。 但是bundler / capistrano指向/ mnt / data-store / project / releases / shared / Gemfile,所以我只是手動復制了兩個文件。 我確定我在這里做錯了。 我想它應該自動復制。

再次執行部署(1)並且它在捆綁安裝上沒有失敗,它甚至有

Your bundle is complete! It was installed into /mnt/data-store/project/shared/bundle Your bundle is complete! It was installed into /mnt/data-store/project/shared/bundle中。

但是,我的一個上限任務執行一個耙子。 結果是:*無法在任何源中找到bcrypt-ruby-3.0.1 *嘗試運行bundle install

繼續我的冒險,我發現一旦你有.bundle / config與BUNDLE_PATH: /mnt/data-store/project/shared/bundle它的工作原理。 我有這個目錄,可能是由bundler在/mnt/data-store/releases/shared/ ,所以我手動復制到rails根目錄。

現在,rake / rails c工作。

bundle show twitter shows .../shared/bundle/ruby/1.9.1/gems/twitter-1.7.1

但是,重新部署將我帶回(1),因為.bundle目錄不存在。

具體問題:

  1. 我是否需要手動創建/復制.bundle / config?
  2. 我是否需要手動將Gemfile / Gemfile.lock復制到共享目錄? 如果我添加寶石怎么辦? 我應該保留兩份副本,還是手動/以編程方式同步它們?
  3. 我究竟做錯了什么?

謝謝!

在deployment.rb文件(Bundler代碼)中查看此部分

args = ["--gemfile #{File.join(context.fetch(:current_release), bundle_gemfile)}"]
args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?

有一個名為:current_release鍵,由於某些原因,這個鍵可能沒有被Capistrano正確設置。

:current_release bundler中的:current_release將指向“共享”文件夾而不是最新版本(帶時間戳)

這將before 'deploy:finalize_update'執行。

我要做的就是在這個事件上添加你自己的鈎子。

before 'deploy:finalize_update', 'x:set_current_release'

這是實際的方法

task :set_current_release, :roles => :app do
    set :current_release, latest_release
end

錯誤

The --deployment flag requires a Gemfile.lock. Please make sure you have checked your Gemfile.lock into version control before deploying.

當服務器上的發行版目錄中存在未解決的內容時發生。 應該只有您的應用程序以前版本的目錄(其名稱以日期開頭,看起來像20111025125442)。

因此,刪除不需要的目錄或文件,然后再次嘗試部署。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM