首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用capistrano和rvm部署-capistrano

使用capistrano和rvm部署-capistrano
EN

Stack Overflow用户
提问于 2012-03-30 21:54:48
回答 1查看 4.6K关注 0票数 2

我正在使用Capistrano来引导一个空的Ubuntu VM。

我有一个安装基本要求的基本配方:

菜谱/base.rb

代码语言:javascript
复制
def set_default(name, *args, &block)
  set(name, *args, &block) unless exists?(name)
end

namespace :deploy do
  desc "Install everything onto the server"
  task :install do
    run "#{sudo} apt-get -y update"

    # Common dependencies
    run "#{sudo} apt-get -y install curl git-core build-essential python-software-properties"
    run "#{sudo} apt-get -y install sudo apt-get -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion"

    # Set timezone to UTC
    run "#{sudo} bash -c 'echo UTC > /etc/timezone'"
    run "#{sudo} cp /usr/share/zoneinfo/UTC /etc/localtime"
    run "#{sudo} dpkg-reconfigure -f noninteractive tzdata"
  end
end

我还有一个安装rvm的方法。我使用rvm-capistrano gem来实现这一点:

食谱/rvm.rb

代码语言:javascript
复制
set_default(:rvm_ruby_string) { "1.9.3@#{application}" }
set_default(:rvm_install_type, :stable)
set_default(:rvm_type, :user)

require 'rvm/capistrano'

after 'deploy:setup', 'rvm:install_rvm'
after 'deploy:setup', 'rvm:install_ruby'

看起来好像rvm-capistrano gem正在修改每个任务的默认外壳并附加:

代码语言:javascript
复制
rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3@application'

这带来的影响是,我的基本配方不再有效,因为它在安装rvm之前运行:

代码语言:javascript
复制
cjoudrey (master) app$ cap deploy:install
  * executing `deploy:install'
  * executing "sudo -p 'sudo password: ' apt-get -y update"
    servers: ["33.33.33.10"]
    [33.33.33.10] executing command
    [33.33.33.10] rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3@app' -c 'sudo -p '\''sudo password: '\'' apt-get -y update'
 ** [out :: 33.33.33.10] bash: /home/vagrant/.rvm/bin/rvm-shell: No such file or directory
    command finished in 45ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3@app' -c 'sudo -p '\\''sudo password: '\\'' apt-get -y update'" on 33.33.33.10
cjoudrey (master) app$

deploy.rb

代码语言:javascript
复制
require 'bundler/capistrano'

load 'config/recipes/base'
load 'config/recipes/rvm'
load 'config/recipes/nginx'
load 'config/recipes/mysql'
load 'config/recipes/nodejs'

server '33.33.33.10', :web, :app, :db, primary: true

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

set :scm, 'git'
set :repository, 'git@github.com:cjoudrey/test.git'
set :branch, 'master'

default_run_options[:pty] = true
ssh_options[:forward_agent] = true
ssh_options[:keys] = `vagrant ssh-config | grep IdentityFile`.split(' ').last

after 'deploy', 'deploy:cleanup'

以前有没有人遇到过这个问题?有没有办法控制rvm-capistrano何时修改默认外壳?也就是说,有没有办法让它不修改deploy:install的默认外壳程序?

我应该只做自己的rvm食谱而不是使用rvm-capistrano吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-30 22:12:23

我遇到了类似的问题,最终在我的deploy.rb中编写了一个disable_rvm_shell函数。我在博客中记录了这一点:Capistrano, system wide RVM and creating gemsets as part of deploy:setup

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9944368

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档