【问题标题】:Capistrano VPS deploy errorCapistrano VPS 部署错误
【发布时间】:2013-04-05 21:55:19
【问题描述】:

我正在使用 Capistrano 部署到 VPS。在我的deploy.rb

require "bundler/capistrano"
server "xxx.xxx.xx.xxx", :web, :app, :db, primary: true
set :application, "riffbox"
set :user, "root"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
set :repository, "https://xxxx@bitbucket.org/xxxx/iv.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the last 5 releases

运行cap deploy:cold时出现以下错误:

  * 2013-04-13 22:59:38 executing `bundle:install'
  * executing "cd /home/root/apps/riffbox/releases/20130413105936 && bundle install --gemfile /home/root/apps/riffbox/releases/20130413105936/Gemfile --path /home/root/apps/riffbox/shared/bundle --deployment --quiet --without development test"
    servers: ["198.199.74.146"]
    [198.199.74.146] executing command
 ** [out :: 198.199.74.146] **ERROR: Gem bundler is not installed, run `gem install bundler` first.**
 ** [out :: 198.199.74.146] 
    command finished in 915ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/root/apps/riffbox/releases/20130413105936; true"
    servers: ["198.199.74.146"]
    [198.199.74.146] executing command
    command finished in 907ms
**failed: "sh -c 'cd /home/root/apps/riffbox/releases/20130413105936 && bundle install --gemfile /home/root/apps/riffbox/releases/20130413105936/Gemfile --path /home/root/apps/riffbox/shared/bundle --deployment --quiet --without development test'" on 198.199.74.146**

我可以看到有两个错误,Bundler 找不到,另一个无法运行sh 命令。我按照说明 (https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm) 使用 root 用户在我的 VPS 上安装了 rvm、rubygem 和 rails。

我还缺少什么?

更新

我正在使用 rvm-capistrano,并使用创建的用户安装了所有内容,但现在 deploy:cold:

执行“如果 [ -d /home/app/riffbox/shared/cached-copy ]; 然后 cd /home/app/riffbox/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 2afbd8fb661f62a01e0940be38e70915fc3e32ea && git clean -q -d -x -f; 否则 git clone -q git@bitbucket.org:xxx/iv.git /home/app/riffbox/shared/cached-copy && cd /home/app/riffbox/shared/cached-copy && git checkout -q -b deploy 2afbd8fb661f62a01e0940be38e70915fc3e32ea;菲“
服务器:[“198.199.74.146”]
密码:
[198.199.74.146] 执行命令
** [198.199.74.146 :: err] 致命:无法读取密码 'https://xxx@bitbucket.org': 没有这样的设备或地址
密码:
命令在 7399 毫秒内完成
* [deploy:update_code] 回滚
* 执行“rm -rf /home/app/riffbox/releases/20130414224249; true”
服务器:[“198.199.74.146”]
[198.199.74.146] 执行命令
命令在 586 毫秒内完成
**失败:“rvm_path=$HOME/.rvm/$HOME/.rvm/bin/rvm-shell '1.9.3@myapp' -c 'if [ -d /home/app/riffbox/shared/cached-copy ]; 然后 cd /home/app/riffbox/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 2afbd8fb661f62a01e0940be38e70915fc3e32ea && git clean -q -d -x -f; 否则 git clone -q git@bitbucket.org:xxx/iv.git /home/app/riffbox/shared/cached-copy && cd /home/app/riffbox/shared/cached-copy && git checkout -q -b deploy 2afbd8fb661f62a01e0940be38e70915fc3e32ea; fi'”在 198.199.74.146

【问题讨论】:

    标签: ruby-on-rails deployment rvm capistrano rvm-capistrano


    【解决方案1】:

    您应该使用rvm-capistrano gem,它可以让您在部署期间访问 RVM 环境。


    一个非常重要的提示:

    您正在使用root 用户进行部署,直接使用root 用户总体上是不好的做法,您应该考虑为每个应用程序使用一个新用户。

    【讨论】:

    • 感谢您的评论。我在 admin 组中创建了一个新用户,但由于“错误:未安装 Gem bundler”而无法使其工作。我的问题是在 VPS 上我应该使用哪个用户(root 或创建的用户)安装 rvm、ruby nginx 等...
    • 是的,为一切创建用户,使用root 是自找麻烦。
    猜你喜欢
    • 1970-01-01
    • 2012-08-06
    • 2015-07-22
    • 1970-01-01
    • 1970-01-01
    • 2016-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多