【问题标题】:Error with cap deploy:cold in Digital Ocean for Rails app上限部署错误:Digital Ocean for Rails 应用程序中的冷
【发布时间】:2015-01-23 17:17:42
【问题描述】:

我真的很想部署一个应用程序,并且一直在关注 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 --deployment --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

部署.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"

还有一些事情

宝石文件:

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'

【问题讨论】:

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


    【解决方案1】:

    您遇到了Cannot allocate memory 错误。这意味着在您的部署机器上没有足够的 RAM 用于打包程序。

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

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

    【讨论】:

    • 非常感谢。我花了很长时间来处理,但它确实解决了这个问题。为了确定,我重新安装了所有东西,Ubuntu 并创建了一个新的应用程序和一个新的 droplet,但我仍然遇到同样的问题。所以,我关注了digitalocean.com/community/tutorials/… 和中提琴!问题消失了....cap deploy:cold...并重新启动了 unicorn 和 nginx...部署了应用...谢谢。
    【解决方案2】:

    我在尝试在 Digital Ocean / Ubuntu 上部署 Dokku 时遇到了类似的问题。 在 root 数字海洋用户的 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/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-04
      • 2015-02-24
      • 1970-01-01
      • 1970-01-01
      • 2020-05-19
      • 2023-04-04
      相关资源
      最近更新 更多