2016-11-05 65 views
0

我正在使用一個數字海洋服務器,我已經成功部署了幾次。突然間,每當我運行cap production deploy它都會失敗,並告訴我有缺失的寶石,其中一些寶石在開發組中,所以它們甚至不應該投入生產。這是我的控制檯輸出與缺少的寶石。還有一些失敗的流程似乎與資產預編譯有關。Capistrano部署Rails應用程序失敗,並說有缺失的寶石

DEBUG [c182dc11] Running [ -L /home/deploy/apps/team_hadley/releases/20161105191648/public/assets ] on 162.243.135.130 
DEBUG [c182dc11] Command: [ -L /home/deploy/apps/team_hadley/releases/20161105191648/public/assets ] 
DEBUG [c182dc11] Finished in 0.062 seconds with exit status 1 (failed). 
DEBUG [5bd74104] Running [ -d /home/deploy/apps/team_hadley/releases/20161105191648/public/assets ] on 162.243.135.130 
DEBUG [5bd74104] Command: [ -d /home/deploy/apps/team_hadley/releases/20161105191648/public/assets ] 
DEBUG [5bd74104] Finished in 0.064 seconds with exit status 1 (failed). 
INFO [92c16c38] Running /usr/bin/env ln -s /home/deploy/apps/team_hadley/shared/public/assets /home/deploy/apps/team_hadley/releases/20161105191648/public/assets on 162.243.135.130 
DEBUG [92c16c38] Command: /usr/bin/env ln -s /home/deploy/apps/team_hadley/shared/public/assets /home/deploy/apps/team_hadley/releases/20161105191648/public/assets 
INFO [92c16c38] Finished in 0.061 seconds with exit status 0 (successful). 
DEBUG [7012f1eb] Running if test ! -d /home/deploy/apps/team_hadley/releases/20161105191648; then echo "Directory does not exist '/home/deploy/apps/team_hadley/releases/20161105191648'" 1>&2; false; fi on 162.243.135.130 
DEBUG [7012f1eb] Command: if test ! -d /home/deploy/apps/team_hadley/releases/20161105191648; then echo "Directory does not exist '/home/deploy/apps/team_hadley/releases/20161105191648'" 1>&2; false; fi 
DEBUG [7012f1eb] Finished in 0.065 seconds with exit status 0 (successful). 
DEBUG [d02096e8] Running ~/.rvm/bin/rvm default do bundle check --path /home/deploy/apps/team_hadley/shared/bundle on 162.243.135.130 


DEBUG [d02096e8] Command: cd /home/deploy/apps/team_hadley/releases/20161105191648 && ~/.rvm/bin/rvm default do bundle check --path /home/deploy/apps/team_hadley/shared/bundle 
DEBUG [d02096e8]  ESC[32mRVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too, 
DEBUG [d02096e8] 
DEBUG [d02096e8]  you can ignore these warnings with 'rvm rvmrc warning ignore /home/deploy/apps/team_hadley/releases/20161105191648/Gemfile'. 
DEBUG [d02096e8] 
DEBUG [d02096e8]  To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'. 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31mThe following gems are missingESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * nokogiri (1.6.8.1)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * globalid (0.3.7)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * net-ssh (3.2.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * net-scp (1.2.1)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * sshkit (1.11.3)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * airbrussh (1.1.1)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * debug_inspector (0.0.2)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * binding_of_caller (0.7.2)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * capistrano-harrow (0.5.3)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * capistrano (3.6.1)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * capistrano-bundler (1.2.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * capistrano-rails (1.1.8)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * capistrano-rvm (0.1.2)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * capistrano-sidekiq (0.5.4)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * capistrano3-puma (1.2.1)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * coderay (1.1.1)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * database_cleaner (1.5.3)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * responders (2.3.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * diff-lcs (1.2.5)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * docile (1.1.5)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * factory_girl (4.7.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * factory_girl_rails (4.7.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * jbuilder (2.6.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * jquery-rails (4.2.1)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * turbolinks (5.0.1)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * materialize-sass (0.97.7)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * method_source (0.8.2)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * slop (3.6.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * pry (0.10.4)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * sprockets (3.7.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * sprockets-rails (3.2.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * react-rails (1.9.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * rspec-support (3.5.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * rspec-core (3.5.4)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * rspec-expectations (3.5.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * rspec-mocks (3.5.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * rspec-rails (3.5.2)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * sass-rails (5.0.6)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * sdoc (0.4.2)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * shoulda-matchers (3.1.1)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * simplecov-html (0.10.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * simplecov (0.11.2)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * spring (2.0.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * sprockets-es6 (0.9.2)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * uglifier (3.0.2)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[31m * web-console (2.3.0)ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8]  ESC[33mInstall missing gems with `bundle install`ESC[0m 
DEBUG [d02096e8] 
DEBUG [d02096e8] Finished in 1.037 seconds with exit status 1 (failed). 
    INFO [62fad7fd] Running ~/.rvm/bin/rvm default do bundle install --path /home/deploy/apps/team_hadley/shared/bundle --without development test --deployment --quiet on 162.243.135.130 
DEBUG [62fad7fd] Command: cd /home/deploy/apps/team_hadley/releases/20161105191648 && ~/.rvm/bin/rvm default do bundle install --path /home/deploy/apps/team_hadley/shared/bundle --without development test --deployment --quiet 
DEBUG [62fad7fd]  ESC[32mRVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too, 
DEBUG [62fad7fd] 
DEBUG [62fad7fd]  you can ignore these warnings with 'rvm rvmrc warning ignore /home/deploy/apps/team_hadley/releases/20161105191648/Gemfile'. 
DEBUG [62fad7fd] 
DEBUG [62fad7fd]  To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'. 
DEBUG [62fad7fd] 
DEBUG [62fad7fd]  ESC[0m 
DEBUG [62fad7fd] 
DEBUG [62fad7fd]  bash: line 1: 7571 Killed     ~/.rvm/bin/rvm default do bundle install --path /home/deploy/apps/team_hadley/shared/bundle --without development test --deployment --quiet 

這裏是我的Capfile:

# Load DSL and Setup Up Stages 
require 'capistrano/setup' 
require 'capistrano/deploy' 

require 'capistrano/rails' 
require 'capistrano/bundler' 
require 'capistrano/rvm' 
require 'capistrano/puma' 

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined. 
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } 

而且我deploy.rb文件:

server '162.243.135.130', port: 22, roles: [:web, :app, :db], primary: true 

set :repo_url,  '[email protected]:mghadley/team_hadley.git' 
set :application,  'team_hadley' 
set :user,   'deploy' 
set :puma_threads, [4, 16] 
set :puma_workers, 0 

# Don't change these unless you know what you're doing 
set :pty,    true 
set :use_sudo,  false 
set :stage,   :production 
set :deploy_via,  :remote_cache 
set :deploy_to,  "/home/#{fetch(:user)}/apps/#{fetch(:application)}" 
set :puma_bind,  "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock" 
set :puma_state,  "#{shared_path}/tmp/pids/puma.state" 
set :puma_pid,  "#{shared_path}/tmp/pids/puma.pid" 
set :puma_access_log, "#{release_path}/log/puma.error.log" 
set :puma_error_log, "#{release_path}/log/puma.access.log" 
set :ssh_options,  { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) } 
set :puma_preload_app, true 
set :puma_worker_timeout, nil 
set :puma_init_active_record, true # Change to false when not using ActiveRecord 

## Defaults: 
# set :scm,   :git 
# set :branch,  :master 
# set :format,  :pretty 
# set :log_level,  :debug 
# set :keep_releases, 5 

## Linked Files & Directories (Default None): 
# set :linked_files, %w{config/database.yml} 
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} 

namespace :puma do 
    desc 'Create Directories for Puma Pids and Socket' 
    task :make_dirs do 
    on roles(:app) do 
     execute "mkdir #{shared_path}/tmp/sockets -p" 
     execute "mkdir #{shared_path}/tmp/pids -p" 
    end 
    end 

    before :start, :make_dirs 
end 

namespace :deploy do 
    desc "Make sure local git is in sync with remote." 
    task :check_revision do 
    on roles(:app) 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 
    end 

    desc 'Initial Deploy' 
    task :initial do 
    on roles(:app) do 
     before 'deploy:restart', 'puma:start' 
     invoke 'deploy' 
    end 
    end 

    desc 'Restart application' 
    task :restart do 
    on roles(:app), in: :sequence, wait: 5 do 
     invoke 'puma:restart' 
    end 
    end 

    before :starting,  :check_revision 
    after :finishing, :compile_assets 
    after :finishing, :cleanup 
    after :finishing, :restart 
end 

# ps aux | grep puma # Get puma pid 
# kill -s SIGUSR2 pid # Restart puma 
# kill -s SIGTERM pid # Stop puma 

而且,最後,我的Gemfile:

source 'https://rubygems.org' 
ruby '2.2.3' 

gem 'rails', '4.2.5' 
gem 'pg', '~> 0.15' 
gem 'sass-rails', '~> 5.0' 
gem 'materialize-sass', '~> 0.97.6' 
gem 'uglifier', '>= 1.3.0' 

gem 'devise', '~> 4.1.1' 

gem 'jquery-rails' 
gem 'jquery-turbolinks' 
gem 'turbolinks' 
gem 'jbuilder', '~> 2.0' 
gem 'sdoc', '~> 0.4.0', group: :doc 

gem "sprockets" 
gem "sprockets-es6" 
gem "react-rails" 
gem "cloudinary" 
gem "jquery-slick-rails" 
gem "sidekiq" 

group :development, :test do 
    gem 'pry', '~> 0.10.3' 
    gem 'rspec-rails' 
    gem 'shoulda-matchers', '~> 3.1.1' 
    gem 'database_cleaner', '~> 1.5.3' 
    gem 'simplecov', '~> 0.11.2' 
    gem 'factory_girl_rails', '~> 4.7.0' 
end 

group :development do 
    gem 'web-console', '~> 2.0' 

    gem 'spring' 

    gem 'capistrano-sidekiq', require: false 
    gem 'capistrano',   require: false 
    gem 'capistrano-rvm',  require: false 
    gem 'capistrano-rails', require: false 
    gem 'capistrano-bundler', require: false 
    gem 'capistrano3-puma', require: false 
end 

group :produection do 
    gem 'rails_12factor' 
    gem 'puma' 
end 

有誰發生知道哪裏出了問題?

回答

2

你會看到從bundle check輸出的寶石丟失。這是預料之中的,因爲Capistrano-bundler在運行bundle install之前首先運行bundle check。您可以忽略check輸出。

真正的問題是你的日誌的最後一行,它說:

bash: line 1: 7571 Killed     ~/.rvm/bin/rvm default do bundle install --path /home/deploy/apps/team_hadley/shared/bundle --without development test --deployment --quiet 

正如你所看到的,bundle install未能由於操作系統被殺死。這幾乎肯定是因爲你已經耗盡了內存,操作系統被迫停止這個過程。

作爲解決方案,您可以將交換添加到您的虛擬機或升級到具有更多內存的虛擬機。

可以肯定的,請檢查日誌/var/log/syslog並查找與內存相關的錯誤。

+0

謝謝!我會試試這個。 – NoTroutAboutIt

+0

如果您不介意的話,您可以跟進一個問題 - 記憶中是否有一個常見問題,或者我應該將此作爲其他問題的標誌? – NoTroutAboutIt

+0

我可以確認添加交換內存在我遇到類似錯誤的情況下工作。 –