上限部署出错:Digital Ocean for Rails应用程序出现冷态问题

时间:2015-01-23 17:17:42

标签: ruby-on-rails capistrano spree railstutorial.org digital-ocean

我真的想部署一个应用程序,并一直关注Michael Hartl的railstutorial。现在,我即将在Digital Ocean部署我的第一个应用程序,但我继续遇到很多问题。无论如何,大部分已经完成,除了这个大的。

我跟随Hoang Pham的这个blog和[Andrew Gertig]的教程[3]。

无论如何,这是我第一次进入这里。我先提前表示感谢。每次我做$ cap deploy:cold,在我的本地机器上,我总是会收到这个错误。

  

失败:“rvm_path = $ HOME / .rvm $ HOME / .rvm / bin / rvm-shell'default'-c   'cd / home / deployer / apps / tiangge / releases / 20150123165947&&束   安装--gemfile   / home / deployer / apps / tiangge / releases / 20150123165947 / Gemfile --path   / home / deployer / apps / tiangge / shared / bundle --demployment --quiet    - 没有开发测试'“在128.199.74.8

我也注意到这一点,这就是我在VPS中再次gem uninstall bundlergem install bundler的原因

[128.199.74.8] executing command  ** [out :: 128.199.74.8] Unfortunately, a fatal error has occurred. Please see the Bundler  **
     

[out :: 128.199.74.8] ** [out :: 128.199.74.8]疑难解答

完整日志:

    triggering load callbacks
  * 2015-01-23 20:59:18 executing `deploy:cold'
  * 2015-01-23 20:59:18 executing `deploy:update'
 ** transaction: start
  * 2015-01-23 20:59:18 executing `deploy:update_code'
    triggering before callbacks for `deploy:update_code'
  * 2015-01-23 20:59:18 executing `sidekiq:quiet'
  * executing "if [ -d /home/deployer/apps/tiangge/current ] && [ -f /home/deployer/apps/tiangge/shared/pids/sidekiq.pid ] && kill -0 `cat /home/deployer/apps/tiangge/shared/pids/sidekiq.pid`> /dev/null 2>&1; then cd /home/deployer/apps/tiangge/current && bundle exec sidekiqctl quiet /home/deployer/apps/tiangge/shared/pids/sidekiq.pid ; else echo 'Sidekiq is not running'; fi"
    servers: ["128.199.74.8"]
deployer@128.199.74.8's password: 
    [128.199.74.8] executing command
 ** [out :: 128.199.74.8] Sidekiq is not running
 ** [out :: 128.199.74.8] 
    command finished in 1328ms
    updating the cached checkout on all servers
    executing locally: "git ls-remote git@bitbucket.org:bryanbenjamin/tiangge.git master"
    command finished in 4069ms
  * executing "if [ -d /home/deployer/apps/tiangge/shared/cached-copy ]; then cd /home/deployer/apps/tiangge/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard d87bdfba0860752edddcf6e8c021c1468367aa03 && git clean -q -d -x -f; else git clone -q -b master git@bitbucket.org:bryanbenjamin/tiangge.git /home/deployer/apps/tiangge/shared/cached-copy && cd /home/deployer/apps/tiangge/shared/cached-copy && git checkout -q -b deploy d87bdfba0860752edddcf6e8c021c1468367aa03; fi"
    servers: ["128.199.74.8"]
    [128.199.74.8] executing command
    command finished in 10461ms
    copying the cached version to /home/deployer/apps/tiangge/releases/20150123165947
  * executing "cp -RPp /home/deployer/apps/tiangge/shared/cached-copy /home/deployer/apps/tiangge/releases/20150123165947 && (echo d87bdfba0860752edddcf6e8c021c1468367aa03 > /home/deployer/apps/tiangge/releases/20150123165947/REVISION)"
    servers: ["128.199.74.8"]
    [128.199.74.8] executing command
    command finished in 1416ms
  * 2015-01-23 20:59:49 executing `deploy:finalize_update'
    triggering before callbacks for `deploy:finalize_update'
  * 2015-01-23 20:59:49 executing `deploy:assets:symlink'
  * executing "rm -rf /home/deployer/apps/tiangge/releases/20150123165947/public/assets && mkdir -p /home/deployer/apps/tiangge/releases/20150123165947/public && mkdir -p /home/deployer/apps/tiangge/shared/assets && ln -s /home/deployer/apps/tiangge/shared/assets /home/deployer/apps/tiangge/releases/20150123165947/public/assets"
    servers: ["128.199.74.8"]
    [128.199.74.8] executing command
    command finished in 1290ms
  * 2015-01-23 20:59:50 executing `bundle:install'
  * executing "cd /home/deployer/apps/tiangge/releases/20150123165947 && bundle install --gemfile /home/deployer/apps/tiangge/releases/20150123165947/Gemfile --path /home/deployer/apps/tiangge/shared/bundle --deployment --quiet --without development test"
    servers: ["128.199.74.8"]
    [128.199.74.8] executing command
 ** [out :: 128.199.74.8] Unfortunately, a fatal error has occurred. Please see the Bundler
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:114:in ``'
 ** [out :: 128.199.74.8] :
 ** [out :: 128.199.74.8] Cannot allocate memory - git clone 'git://github.com/spree/spree_auth_devise.git' "/home/deployer/apps/tiangge/shared/bundle/ruby/2.1.0/cache/bundler/git/spree_auth_devise-68351354588ecb7fa5d7bc278ebd86436a50d33d" --bare --no-hardlinks --quiet
 ** [out :: 128.199.74.8] (
 ** [out :: 128.199.74.8] Errno::ENOMEM
 ** [out :: 128.199.74.8] )
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:114:in `block in git'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/shared_helpers.rb:62:in `call'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/shared_helpers.rb:62:in `with_clean_git_env'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:114:in `git'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:108:in `block in git_retry'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/retry.rb:38:in `call'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/retry.rb:38:in `run'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/retry.rb:28:in `attempt'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:107:in `git_retry'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:73:in `checkout'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git.rb:149:in `specs'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/lazy_specification.rb:53:in `__materialize__'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/spec_set.rb:88:in `block in materialize'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/spec_set.rb:85:in `map!'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/spec_set.rb:85:in `materialize'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/definition.rb:132:in `specs'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/definition.rb:121:in `resolve_remotely!'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/installer.rb:79:in `run'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/installer.rb:18:in `install'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/cli/install.rb:79:in `run'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/cli.rb:145:in `install'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/vendor/thor/command.rb:27:in `run'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/vendor/thor/invocation.rb:121:in `invoke_command'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/vendor/thor.rb:363:in `dispatch'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/vendor/thor/base.rb:440:in `start'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/cli.rb:9:in `start'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/bin/bundle:20:in `block in <top (required)>'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/bin/bundle:18:in `<top (required)>'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/bin/bundle:23:in `load'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/bin/bundle:23:in `<main>'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `eval'
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] 
 ** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `<main>'
 ** [out :: 128.199.74.8] 
    command finished in 56236ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/deployer/apps/tiangge/releases/20150123165947; true"
    servers: ["128.199.74.8"]
    [128.199.74.8] executing command
    command finished in 1335ms
failed: "rvm_path=$HOME/.rvm $HOME/.rvm/bin/rvm-shell 'default' -c 'cd /home/deployer/apps/tiangge/releases/20150123165947 && bundle install --gemfile /home/deployer/apps/tiangge/releases/20150123165947/Gemfile --path /home/deployer/apps/tiangge/shared/bundle --deployment --quiet --without development test'" on 128.199.74.8

deploy.rb

require "bundler/capistrano"
require "rvm/capistrano"
require 'capistrano/sidekiq'


server "128.199.74.8", :web, :app, :db, primary: true

set :application, "tiangge"
set :user, "deployer"
set :port, 6000
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false

set :scm, "git"
set :repository, "git@bitbucket.org:bryanbenjamin/tiangge.git"
set :branch, "master"

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

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 #{shared_path}/config/database.yml and add your username and password"
  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

我已经完成的步骤:

- 重新安装捆绑包和 在deploy.rb中使用set :rvm_bin_path, "/usr/share/ruby-rvm/bin"

和一些事情

的Gemfile:

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

gem 'rails', '4.1.8'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc

gem 'spring',        group: :development

gem 'unicorn'
gem 'capistrano'
gem 'rvm-capistrano'
gem 'dotenv-rails'
gem 'capistrano-sidekiq'


gem 'spree', '2.4.2'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '2-4-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-4-stable'

2 个答案:

答案 0 :(得分:0)

您遇到Cannot allocate memory错误。这意味着您的部署机器上没有足够的RAM用于捆绑器。

您可以添加交换分区来执行此操作,或创建具有更大RAM空间的DO小滴。

关于向DO droplet添加交换的好教程https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-12-04

答案 1 :(得分:0)

我在尝试在Digital Ocean / Ubuntu上部署Dokku时遇到了类似的问题。 在根数字海洋用户的SSH会话中运行3行代码轻松修复:

dd if=/dev/zero of=/swapfile bs=1024 count=1024000
mkswap /swapfile
swapon /swapfile

参考:http://dev.housetrip.com/2014/07/06/deploy-rails-and-postgresql-app-to-dokku/