每个上限的服务器上的机架错误:部署

时间:2012-01-24 16:20:38

标签: ruby-on-rails-3.1 annotations rake capistrano bundler

每次我在本地计算机cap:deploy上运行时,当我打开网页时出现下一个错误:

Ruby (Rack) application could not be started
Error message:
git://github.com/ctran/annotate_models.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
Exception class:
PhusionPassenger::UnknownError
Application root:
/vol/www/apps/ror_tutorial/current
Backtrace:
#
File
Line
Location
0
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/source.rb
572
in `rescue in load_spec_files'
1
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/source.rb
570
in `load_spec_files'
2
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/source.rb
385
in `local_specs'
3
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/source.rb
555
in `specs'
4
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/definition.rb
147
in `block in resolve'
5
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/definition.rb
145
in `each'
6
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/definition.rb
145
in `resolve'
7
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/definition.rb
90
in `specs'
8
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/definition.rb
135
in `specs_for'
9
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/definition.rb
124
in `requested_specs'
10
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/environment.rb
23
in `requested_specs'
11
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/runtime.rb
11
in `setup'
12
/usr/local/rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler.rb
110
in `setup'
13
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/utils.rb
326
in `prepare_app_process'
14
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb
156
in `block in initialize_server'
15
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/utils.rb
572
in `report_app_init_status'
16
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb
154
in `initialize_server'
17
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb
204
in `start_synchronously'
18
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb
180
in `start'
19
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb
129
in `start'
20
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb
253
in `block (2 levels) in spawn_rack_application'
21
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server_collection.rb
132
in `lookup_or_add'
22
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb
246
in `block in spawn_rack_application'
23
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server_collection.rb
82
in `block in synchronize'
24

prelude>
10:in `synchronize'
25
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server_collection.rb
79
in `synchronize'
26
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb
244
in `spawn_rack_application'
27
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb
137
in `spawn_application'
28
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb
275
in `handle_spawn_application'
29
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb
357
in `server_main_loop'
30
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb
206
in `start_synchronously'
31
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11/helper-scripts/passenger-spawn-server
99
in `'

我通过下一行解决了这个问题:

$ bundle install --without development test
$ bundle install --deployment
$ service nginx restart

但我真的厌倦了一次又一次地这样做。有谁知道如何永远修复它?

我的宝石文件:

source 'http://rubygems.org'

gem 'rails', '3.1.3'                                                          
gem 'gravatar_image_tag'
gem 'will_paginate'
gem 'rack'                                                                    
gem 'rake'                                                                    
gem 'texticle', "2.0", :require => 'texticle/rails'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails'                                                            
  gem 'coffee-rails'                                                          
  gem 'uglifier'
end

gem 'jquery-rails'

group :development do
  gem 'capistrano'
  gem 'rspec-rails'                                                          
  gem 'therubyracer-heroku'
  gem 'pg'                                                                     
  gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'        
  gem 'faker'                                                                 
end

group :test do
  gem 'rspec-rails'                                                           
  gem 'webrat'                                                                
  gem 'spork'
  gem 'autotest'                                                                                                               
  gem 'autotest-rails-pure'                                                                                                  
  gem 'autotest-fsevent'                                                      
  gem 'autotest-growl'                                                                                                     
  gem 'factory_girl_rails'
end

group :production do  
  gem 'pg'                                                                    
  gem 'faker'
end

配置/ deploy.rb

set :user, "root"                                                                 
set :rails_env, "production"

default_run_options[:pty] = true                                              
set :repository,  "git://github.com/Loremaster/sample_app.git"

set :application, "ror_tutorial"
set :deploy_to, "/vol/www/apps/#{application}"

set :scm, :git
set :branch, "master"
set :deploy_via, :remote_cache                                                

server "my.ip", :app,
                          :web,
                          :db, :primary => true


# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
   task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
   end
end

我的服务器系统:

Ubuntu 10.04 LTS
PostgreSQL 9.1
Rails 3.1.3
Ruby 1.9.3p27
Nginx 1.0.11 (installed/compiled by passenger)
Phusion passenger 3.0.11
Capistrano

2 个答案:

答案 0 :(得分:7)

除非您指定在deploy.rb中使用bundler,否则

capistrano不会自动运行bundler命令。我将此行添加到deploy.rb文件的顶部以激活bundler集成。然后Capistrano在部署时自动运行正确的捆绑命令。

require 'bundler/capistrano'  # Add Bundler integration to capistrano

运行bundle install --without development testbundle install --deployment的解决方案实际上是相同的,但必须手动保持最新。此外,您可以将其提炼为单个命令:bundle install --deployment --without development test。在当前的解决方案中,您运行了两次捆绑包。

答案 1 :(得分:0)

我遇到了同样的问题。在我们的5个环境中,我们的暂存环境开始实现这一目标。我无法找到原因,但我终于可以通过备份然后重新创建我们的部署目录进行部署,然后是cap deploy:setup,cap deploy:cold then cap deploy