通过部署Railscast食谱寻找RVM

时间:2013-09-06 13:09:35

标签: ruby-on-rails nginx capistrano unicorn

我在这个railscast上花了好几个小时http://railscasts.com/episodes/335-deploying-to-a-vps,本教程https://coderwall.com/p/yz8cha(which基于railscast)

当我进行上限部署时,我得到了这个:设置或捆绑exec cap deploy:setup

我不太熟悉railscast上使用的脚本,主要是在根路径上复制和粘贴/扩充路径(插入用户名/项目名称)。我怀疑我错误地配置了脚本?

cap deploy:setup
triggering load callbacks
* 2013-09-06 01:21:56 executing `deploy:setup'
* executing "mkdir -p /home/deployer2/apps/lintong /home/deployer2/apps/lintong/releases /home/deployer2/apps/lintong/shared /home/deployer2/apps/lintong/shared/system /home/deployer2/apps/lintong/shared/log /home/deployer2/apps/lintong/shared/pids"
servers: ["192.241.241.204"]
[192.241.241.204] executing command
** [out :: 192.241.241.204] bash: /home/deployer2/.rvm/bin/rvm-shell: No such file or directory
command finished in 9ms
failed: "rvm_path=$HOME/.rvm $HOME/.rvm/bin/rvm-shell 'default' -c 'mkdir -p /home/deployer2/apps/lintong /home/deployer2/apps/lintong/releases /home/deployer2/apps/lintong/shared /home/deployer2/apps/lintong/shared/system /home/deployer2/apps/lintong/shared/log /home/deployer2/apps/lintong/shared/pids'" on 192.241.241.204

这是我的deploy.rb文件

require "bundler/capistrano"
require "rvm/capistrano"

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

set :application, "lintong"
set :user, "deployer2"
set :port, 7000
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false

set :scm, "git"
set :repository, "git@github.com:Jngai/#{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
  %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 the config files in #{shared_path}."
  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

它在错误的地方寻找rvm?它生活在usr / local。是否有人熟悉使用Capistrano进行部署?

1 个答案:

答案 0 :(得分:0)

我在deploy.rb

中缺少这个
set :rvm_ruby_string, :local # use the same ruby as used locally for deployment
before 'deploy:setup', 'rvm:install_rvm'  # install/update RVM
before 'deploy:setup', 'rvm:install_ruby' # install Ruby and create gemset, OR: