2012-06-14 115 views
1

我試圖部署到Ryan Bates截屏視頻後的VPS。Capistrano抱怨資產預編譯時缺少'eventmachine'

我用細如Web服務器而不是獨角獸和它給我頭疼的負荷...... 當試圖編譯服務器上的資產,它給了我這樣的:

triggering after callbacks for `deploy:update_code' 
* executing `deploy:assets:precompile' 
* executing "cd /home/deployer/apps/my-app/releases/20120614062157 && b 
undle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile" 
servers: ["**.**.**.**"] 
[xx.xx.xx.xx] executing command 
** [out :: **.**.**.**] rake aborted! 
** [out :: **.**.**.**] cannot load such file -- eventmachine 
** [out :: **.**.**.**] 
** [out :: **.**.**.**] (See full trace by running task with --trace) 
command finished in 3891ms 
*** [deploy:update_code] rolling back 
* executing "rm -rf /home/deployer/apps/my-app/releases/20120614062157; 
true" 
servers: ["**.**.**.**"] 
[**.**.**.**] executing command 

我不能檢查如果eventmachine安裝在捆綁包中,因爲capistrano總是將所有內容都回滾,所以我實際上並沒有在腳本之後安裝應用程序..這使得幾乎不可能追溯到更遠......

所以我完全失去了。谷歌搜索「耙資產:預編譯eventmachine」不返回任何相關的..

謝謝你的幫助。

親切的問候 斯特凡諾

我的Gemfile:

source 'http://rubygems.org' 

gem 'rails', '3.2.2' 

# Bundle edge Rails instead: 
# gem 'rails', :git => 'git://github.com/rails/rails.git' 

# gem 'sqlite3' 
gem 'pg' 
gem 'bootstrap-sass-rails' 

group :development do 
    # To generate the class diagrams. 
    gem 'annotate', :git => 'git://github.com/jeremyolliver/annotate_models.git', :branch => 'rake_compatibility' 
end 

group :test do 
    gem 'rspec-rails' 
    gem 'capybara' 
    gem 'spork', '0.9.0' 
    gem 'factory_girl_rails' 
    gem 'guard-spork', '0.3.2' 
end 

# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '~> 3.2.3' 
    gem 'coffee-rails', '~> 3.2.1' 

    # See https://github.com/sstephenson/execjs#readme for more supported runtimes 
    # gem 'therubyracer' 

    gem 'uglifier', '>= 1.0.3' 
end 

gem 'jquery-rails' 

#To use ActiveModel has_secure_password 
gem 'bcrypt-ruby', '~> 3.0.0' 

# Form helpers 
gem 'simple_form' 
gem 'country_select' 

# RMagick 
gem 'mini_magick' 

# Active merchant 
gem 'activemerchant', :require => 'active_merchant' 

# To validate IBAN numbers 
gem 'iban-tools' 

# For the google maps stuff 
gem 'gmaps4rails' 

# To generate PDFs 
gem 'prawn', '1.0.0.rc1' 

# HAML test 
gem 'haml' 
gem 'haml-rails' 

# For HTML emails 
gem 'roadie' 

# To use Jbuilder templates for JSON 
# gem 'jbuilder' 

# Use unicorn as the app server 
# gem 'unicorn' 

# gem "thin", "1.3.1" 
# gem "unicorn" 

# Deploy with Capistrano 
gem 'capistrano' 

platform :ruby do 
    gem "unicorn" 
end 

# To use debugger 
# gem 'ruby-debug19', :require => 'ruby-debug' 

正如你看到的我swaped薄的麒麟......我想我也把範圍縮小到Capistrano的實際上從未叫包安裝?因爲現在它抱怨沒有找到nokogiri。

我設法找到capistrano存儲在共享/緩存複製目錄下的服務器上的實際版本,並且捆綁安裝在那裏工作得很好!

是的'用導軌部署很容易!'容易浪費整整一個星期就可以了..

捆綁安裝的作品,如果我做捆綁高管帽部署:

triggering after callbacks for `deploy:finalize_update' 
    * executing `bundle:install' 
    * executing "ls -x /home/deployer/apps/hemd-mit-stil/releases" 
    servers: ["xx.xx.xx.xx"] 
    [xx.xx.xx.xx] executing command 
    command finished in 1453ms 
    * executing "cd /home/deployer/apps/hemd-mit-stil/releases/20120615043946 && b 
undle install --gemfile /home/deployer/apps/hemd-mit-stil/releases/2012061504394 
6/Gemfile --path /home/deployer/apps/hemd-mit-stil/shared/bundle --deployment -- 
quiet --without development test" 
    servers: ["xx.xx.xx.xx"] 
    [xx.xx.xx.xx] executing command 
    command finished in 29813ms 
    * executing `deploy:symlink_config' 
    * executing "ln -nfs /home/deployer/apps/hemd-mit-stil/shared/config/database. 
yml /home/deployer/apps/hemd-mit-stil/releases/20120615043946/config/database.ym 
l" 
    servers: ["xx.xx.xx.xx"] 
    [xx.xx.xx.xx] executing command 
    command finished in 1484ms 
    triggering after callbacks for `deploy:update_code' 
    * executing `deploy:assets:precompile' 
    * executing "cd /home/deployer/apps/hemd-mit-stil/releases/20120615043946 && b 
undle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile" 
    servers: ["xx.xx.xx.xx"] 
    [xx.xx.xx.xx] executing command 
** [out :: xx.xx.xx.xx] rake aborted! 
** [out :: xx.xx.xx.xx] cannot load such file -- nokogiri 
** [out :: xx.xx.xx.xx] 
** [out :: xx.xx.xx.xx] (See full trace by running task with --trace) 
    command finished in 3563ms 
*** [deploy:update_code] rolling back 
    * executing "rm -rf /home/deployer/apps/hemd-mit-stil/releases/20120615043946; 
true" 
    servers: ["xx.xx.xx.xx"] 
    [xx.xx.xx.xx] executing command 
    command finished in 1453ms 
failed: "sh -c 'cd /home/deployer/apps/hemd-mit-stil/releases/20120615043946 && 
bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on 
xx.xx.xx.xx 

我deploy.rb文件(從railscasts基本上直副本)

require "bundler/capistrano" 

server "xx.xx.xx.xx", :web, :app, :db, primary: true 

set :application, "hemd-mit-stil" 
set :user, "deployer" 
set :deploy_to, "/home/#{user}/apps/#{application}" 
set :deploy_via, :remote_cache 
set :use_sudo, false 

set :scm, "git" 
set :repository, "[email protected]:Stefano1990/#{application}.git" 
set :branch, "master" 

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

after "deploy", "deploy:cleanup" # keep only the last 5 releases 

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 
+0

你能運行rake RAILS_ENV =生產RAILS_GROUPS =資產在本地? –

+0

是的,在當地它工作得很好。與此同時,我試圖在服務器上手動克隆git存儲庫,然後編譯資產並且工作得很好。 – KimJongIl

+0

這聽起來像是某種薄弱的問題(因爲薄弱的在幕後使用EM)。我之前沒有遇到過這個問題,所以我沒有答案,對不起。 – Andrew

回答

2

我居然發現了問題...

如果你把你Gemfile.lock的在你的倉庫(推薦),你產生Gemfile.lock的Windows機器上你基本上擰緊。

一個從Windows機器Gemfile.lock的會做到這一點:

bcrypt-ruby (3.0.1-x86-mingw32) 

而且在生產環境(Linux版),這將靜默失敗。

「解決方案」: 不要在您的版本控制中檢查Gemfile.lock。這可能會在稍後重新部署時導致問題,並且您的應用程序決定更新它的寶石,因爲它會生成Gemfile.lock本身。

的 「真正解」: 不要工作在Windows上。

從您的資料庫中刪除您Gemfile.lock的事:

git rm Gemfile.lock 
+0

@KimJongII,我非常愛你。在這一點上,現在結束了5小時在iterwebs上尋找解決此問題的解決方案。 您仍可以檢查您的Gemfile.lock的文件到你的資料庫,但我沒有犯以前以下... 在Gemfile.lock的 替換:bcrypt - 紅寶石(3.0.1 86的mingw32) 帶:bcrypt -ruby(3.0.1) 這非常冒險,每次運行軟件包更新時我都需要這樣做,但我現在不在意,而且我是一個快樂的人。你不喜歡這在將近2年後仍然是個問題嗎? – Venice

+0

我不會評論bundler的做法。我向捆綁商提出了這個問題,但他們不認爲它是一個問題... – KimJongIl

0

你不需要cap deploy:cold,但你需要確保你的capistrano腳本知道bundle install。所有你需要做的是require 'bundler/capistrano'。這應有助於:http://gembundler.com/deploying.html

+0

我很害怕仍然無法正常工作..我完全重新安裝了VPS,但它又一次陷入了同樣的一步。輸出附加到我的問題。 – KimJongIl

+0

你可以發佈你的deploy.rb文件嗎?我認爲問題出在 – Andrew

+0

已經完成,看到我的問題。 – KimJongIl