1

我正在尝试使用 capistrano 将我的应用程序部署到 DigitalOcean 服务器。一切都会好起来的,接受我无法通过网络访问我的应用程序并看到“504 网关超时”。cap deploy 成功结束,但似乎 unicorn 没有启动。我将 multi_json 添加到我的 Gemfile 中并尝试了包更新。multi_json 1.8.0 在我的 gem 列表中,但在我的 /home/unicorn/log/unicorn.log 文件中,我可以看到以下内容:

E, [2013-09-20T07:53:54.994778 #26940] ERROR -- : Could not find multi_json-1.8.0 in any of the sources (Bundler::GemNotFound)
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/definition.rb:159:in `specs_for'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/definition.rb:148:in `requested_specs'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/environment.rb:18:in `requested_specs'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:13:in `setup'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/home/rails/releases/20130919221638/config/boot.rb:6:in `<top (required)>'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/rails/releases/20130919221638/config/application.rb:1:in `<top (required)>'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/rails/releases/20130919221638/config/environment.rb:2:in `<top (required)>'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
config.ru:4:in `block in <main>'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn.rb:48:in `eval'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn.rb:48:in `block in builder'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:722:in `call'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:722:in `build_app!'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:595:in `init_worker_process'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:615:in `worker_loop'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:511:in `maintain_worker_count'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:277:in `join'
/usr/bin/unicorn:121:in `<main>'
E, [2013-09-20T07:53:55.003072 #766] ERROR -- : reaped #<Process::Status: pid 26940 exit 1> worker=0
I, [2013-09-20T07:53:55.003306 #766]  INFO -- : worker=0 spawning...
I, [2013-09-20T07:53:55.009659 #26952]  INFO -- : worker=0 spawned pid=26952
I, [2013-09-20T07:53:55.033969 #26952]  INFO -- : Refreshing Gem list

在我的 deploy.rb 中,我有以下独角兽启动说明:

namespace :deploy do
  task :restart do
    run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -USR2 `cat #{unicorn_pid}`; else cd #{deploy_to}/current && unicorn -c #{unicorn_conf} -E #{rails_env} -D; fi"
  end
  task :start do
    run "unicorn -c #{unicorn_conf} -E #{rails_env} -D"
  end
  task :stop do
    run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -QUIT `cat #{unicorn_pid}`; fi"
  end
end

我正在使用 Ubuntu 12.10 (GNU/Linux 3.5.0-17-generic x86_64)、nginx、unicorn、mysql Rails 3.2.13 Ruby 1.9.3 我的 Gemfile 是:

source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'cancan'
gem 'devise'
gem 'paperclip'
gem 'nested_form'
gem 'gmaps4rails'
gem 'activeadmin'
gem 'meta_search',  '>= 1.1.0.pre'
gem 'country-select'
gem 'therubyracer'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
gem 'multi_json'
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails', '< 3.0.0'
ruby '1.9.3'
gem 'unicorn'
gem 'sqlite3'
group :development do
  gem 'capistrano'
  gem 'rvm-capistrano'
end
group :production do
  gem 'mysql2'
end

我的 Gemfile.lock 是:

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.13)
      actionpack (= 3.2.13)
      mail (~> 2.5.3)
    actionpack (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.5)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.2.1)
    activeadmin (0.6.0)
      arbre (>= 1.0.1)
      bourbon (>= 1.0.0)
      devise (>= 1.1.2)
      fastercsv
      formtastic (>= 2.0.0)
      inherited_resources (>= 1.3.1)
      jquery-rails (>= 1.0.0)
      kaminari (>= 0.13.0)
      meta_search (>= 0.9.2)
      rails (>= 3.0.0)
      sass (>= 3.1.0)
    activemodel (3.2.13)
      activesupport (= 3.2.13)
      builder (~> 3.0.0)
    activerecord (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
    activesupport (3.2.13)
      i18n (= 0.6.1)
      multi_json (~> 1.0)
    arbre (1.0.1)
      activesupport (>= 3.0.0)
    arel (3.0.2)
    atomic (1.1.14)
    bcrypt-ruby (3.1.2)
    bourbon (3.1.8)
      sass (>= 3.2.0)
      thor
    builder (3.0.4)
    cancan (1.6.10)
    capistrano (2.15.5)
      highline
      net-scp (>= 1.0.0)
      net-sftp (>= 2.0.0)
      net-ssh (>= 2.0.14)
      net-ssh-gateway (>= 1.1.0)
    climate_control (0.0.3)
      activesupport (>= 3.0)
    cocaine (0.5.1)
      climate_control (>= 0.0.3, < 1.0)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.3)
    commonjs (0.2.7)
    country-select (1.1.1)
    devise (3.1.0)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      thread_safe (~> 0.1)
      warden (~> 1.2.3)
    erubis (2.7.0)
    execjs (2.0.1)
    fastercsv (1.5.5)
    formtastic (2.2.1)
      actionpack (>= 3.0)
    gmaps4rails (1.5.6)
    has_scope (0.6.0.rc)
      actionpack (>= 3.2, < 5)
      activesupport (>= 3.2, < 5)
    highline (1.6.19)
    hike (1.2.3)
    i18n (0.6.1)
    inherited_resources (1.4.1)
      has_scope (~> 0.6.0.rc)
      responders (~> 1.0.0.rc)
    journey (1.0.4)
    jquery-rails (2.3.0)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.8.0)
    kaminari (0.14.1)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    kgio (2.8.1)
    less (2.4.0)
      commonjs (~> 0.2.7)
    less-rails (2.4.2)
      actionpack (>= 3.1)
      less (~> 2.4.0)
    libv8 (3.16.14.3)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    meta_search (1.1.3)
      actionpack (~> 3.1)
      activerecord (~> 3.1)
      activesupport (~> 3.1)
      polyamorous (~> 0.5.0)
    mime-types (1.25)
    multi_json (1.8.0)
    mysql2 (0.3.13)
    nested_form (0.3.2)
    net-scp (1.1.2)
      net-ssh (>= 2.6.5)
    net-sftp (2.1.2)
      net-ssh (>= 2.6.5)
    net-ssh (2.7.0)
    net-ssh-gateway (1.2.0)
      net-ssh (>= 2.6.5)
    orm_adapter (0.4.0)
    paperclip (3.5.1)
      activemodel (>= 3.0.0)
      activesupport (>= 3.0.0)
      cocaine (~> 0.5.0)
      mime-types
    polyamorous (0.5.0)
      activerecord (~> 3.0)
    polyglot (0.3.3)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.13)
      actionmailer (= 3.2.13)
      actionpack (= 3.2.13)
      activerecord (= 3.2.13)
      activeresource (= 3.2.13)
      activesupport (= 3.2.13)
      bundler (~> 1.0)
      railties (= 3.2.13)
    railties (3.2.13)
      actionpack (= 3.2.13)
      activesupport (= 3.2.13)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    raindrops (0.12.0)
    rake (10.1.0)
    rdoc (3.12.2)
      json (~> 1.4)
    ref (1.0.5)
    responders (1.0.0.rc)
      railties (>= 3.2, < 5)
    rvm-capistrano (1.5.0)
      capistrano (>= 2.15.4)
    sass (3.2.10)
    sass-rails (3.2.6)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.8)
    therubyracer (0.12.0)
      libv8 (~> 3.16.14.0)
      ref
    thor (0.18.1)
    thread_safe (0.1.3)
      atomic
    tilt (1.4.1)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    twitter-bootstrap-rails (2.2.8)
      actionpack (>= 3.1)
      execjs
      rails (>= 3.1)
      railties (>= 3.1)
    tzinfo (0.3.37)
    uglifier (2.2.1)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    unicorn (4.6.3)
      kgio (~> 2.6)
      rack
      raindrops (~> 0.7)
    warden (1.2.3)
      rack (>= 1.0)

PLATFORMS
  ruby

DEPENDENCIES
  activeadmin
  cancan
  capistrano
  coffee-rails (~> 3.2.1)
  country-select
  devise
  gmaps4rails
  jquery-rails (< 3.0.0)
  less-rails
  meta_search (>= 1.1.0.pre)
  multi_json
  mysql2
  nested_form
  paperclip
  rails (= 3.2.13)
  rvm-capistrano
  sass-rails (~> 3.2.3)
  sqlite3
  therubyracer
  twitter-bootstrap-rails
  uglifier (>= 1.0.3)
  unicorn
4

2 回答 2

2

问题是通过执行:bundle install --no-deployment通过 ssh 然后用 bundle exec 启动 unicorn 解决的:bundle exec unicorn -c /home/rails/current/config/unicorn.rb -E production -D

于 2013-09-20T18:46:10.747 回答
0

尝试添加set :rvm_type, :system到您的 deploy.rb。在部署期间,capistrano 可能正在使用用户 rvm,而从您的输出看来,独角兽正在使用系统 rvm。

于 2013-09-20T12:20:55.907 回答