繁体   English   中英

capistrano cap deploy:冷错误

[英]capistrano cap deploy:cold error

生产服务器:Ubuntu 12.04,Apache,Passenger,RVM,Ruby 2,Rails 4,Postgresql

在cap deploy:cold后出现此错误(我更改了用户名和IP):

* 2013-03-04 12:17:56 executing `deploy:cold'
  * 2013-03-04 12:17:56 executing `deploy:update'
 ** transaction: start
  * 2013-03-04 12:17:56 executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote git@github.com:user/captest.git master"
    command finished in 4655ms
  * executing "if [ -d /home/user/apps/captest/shared/cached-copy ]; then cd /home/user/apps/captest/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 0ad1ab0c9e73b41959981a1415f71a42e80c0443 && git clean -q -d -x -f; else git clone -q git@github.com:user/captest.git /home/user/apps/captest/shared/cached-copy && cd /home/user/apps/captest/shared/cached-copy && git checkout -q -b deploy 0ad1ab0c9e73b41959981a1415f71a42e80c0443; fi"
    servers: ["192.33.33.333"]
    [192.33.333.333] executing command
    command finished in 5870ms
    copying the cached version to /home/user/apps/captest/releases/20130304111807
  * executing "cp -RPp /home/user/apps/captest/shared/cached-copy /home/user/apps/captest/releases/20130304111807 && (echo 0ad1ab0c9e73b41959981a1415f71a42e80c0443 > /home/user/apps/captest/releases/20130304111807/REVISION)"
    servers: ["192.33.333.333"]
    [192.33.333.333] executing command
    command finished in 122ms
  * 2013-03-04 12:18:07 executing `deploy:finalize_update'
    triggering before callbacks for `deploy:finalize_update'
  * 2013-03-04 12:18:07 executing `deploy:assets:symlink'
  * executing "rm -rf /home/user/apps/captest/releases/20130304111807/public/assets && mkdir -p /home/user/apps/captest/releases/20130304111807/public && mkdir -p /home/user/apps/captest/shared/assets && ln -s /home/user/apps/captest/shared/assets /home/user/apps/captest/releases/20130304111807/public/assets"
    servers: ["192.33.333.333"]
    ["192.33.333.333"] executing command
    command finished in 134ms
  * 2013-03-04 12:18:07 executing `bundle:install'
  * executing "cd /home/user/apps/captest/releases/20130304111807 && bundle install --gemfile /home/user/apps/captest/releases/20130304111807/Gemfile --path /home/user/apps/captest/shared/bundle --deployment --quiet --without development test"
    servers: ["192.33.333.333"]
    [192.33.333.333] executing command
 ** [out :: 192.33.333.333] sh: 1:
 ** [out :: 192.33.333.333] bundle: not found
 ** [out :: 192.33.333.333] 
    command finished in 110ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/user/apps/captest/releases/20130304111807; true"
    servers: ["192.33.333.333"]
    [192.33.333.333] executing command
    command finished in 118ms
failed: "sh -c 'cd /home/user/apps/captest/releases/20130304111807 && bundle install --gemfile /home/user/apps/captest/releases/20130304111807/Gemfile --path /home/user/apps/captest/shared/bundle --deployment --quiet --without development test'" on 192.33.333.333

我基本上遵循了railscasts情节“部署到vps”的指示。 这是我的deploy.rb文件:

require "bundler/capistrano"


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

set :application, "captest"
set :user, "user"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false

set :scm, "git"
set :repository, "git@github.com:user/#{application}.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
  task :start do; end
  task :stop do; end
  task :restart, roles: :app, except: {no_release: true} do
    run "touch #{deploy_to}/current/tmp/restart.txt"
  end

  task :setup_config, roles: :app do
    sudo "ln -nfs #{current_path}/config/apache.conf /etc/apache2/sites-available/#{application}"
    run "mkdir -p #{shared_path}/config"
    put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
    puts "Now edit the config files in #{shared_path}."
  end
  after "deploy:setup", "deploy:setup_config"
end

我尝试直接从服务器安装捆绑软件,但不知道在哪里,因为我对应用程序结构感到困惑。 还尝试了“要求rvm / capistrano”,但也出现错误。

您仍然看不到真正的错误是什么。

如果cap deploy:cold命令上的-v(表示详细信息)没有告诉您真正的问题,请ssh进入服务器并运行以下命令: cd /home/user/apps/captest/releases/20130304111807 && bundle install --gemfile /home/user/apps/captest/releases/20130304111807/Gemfile --path /home/user/apps/captest/shared/bundle --deployment --quiet --without development test

听起来您的ruby env可能未在服务器上正确设置。

编辑:实际上,如果将其删除则可能无法正常工作。 我遇到了类似的问题,我通过将项目手动克隆到生产服务器并运行捆绑安装来调试任何问题来解决了该问题。

您需要在目标服务器上安装捆绑程序。

gem install bundler

通常,它是唯一需要以这种方式安装的gem,因为它本身无法安装。

这个要点并不完全适合您的需求,而是我如何引导Ruby 2.0 Ubuntu服务器,并且可能会有所帮助: https : //gist.github.com/cmaitchison/4083459

我遇到了同样的问题,并确定了解决方案。

在您的服务器上,卸载所有版本的Bundler。 系统将提示您删除可执行文件。 选择是。 然后gem install bundler应该安装1.3.2或更高版本。

在您的Gemfile中,确保源是https而不是http source 'https://rubygems.org'

引用: https : //github.com/carlhuda/bundler/issues/2378#issuecomment-14714639

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM