繁体   English   中英

Capistrano导轨部署失败

[英]Capistrano rails deploy fail

当我尝试使用capistrano进行部署时,出现错误

/home/username/.rvm/gems/ruby-2.0.0-p0@dvr/gems/capistrano-2.15.5/lib/capistrano/recipes/deploy/assets.rb:28:in `parse_manifest': undefined method `to_a' for #<String:0x9fa62d0> (NoMethodError)

此外,在输出中,我有多个实例:

** [out :: *IP_HERE*] SHELL=/bin/bash
** [out :: *IP_HERE*] SSH_CLIENT=*IP_HERE* 53366 22
** [out :: *IP_HERE*] USER=root
** [out :: *IP_HERE*] MAIL=/var/mail/root
** [out :: *IP_HERE*] PATH=/usr/local/rvm/gems/ruby-2.0.0-p247/bin:/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin:/usr/local/rvm/rubies/ruby-2.0.0-p247/bin:/home/rails/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
** [out :: *IP_HERE*] PWD=/root
** [out :: *IP_HERE*] LANG=en_US.UTF-8
** [out :: *IP_HERE*] SHLVL=1
** [out :: *IP_HERE*] HOME=/root
** [out :: *IP_HERE*] LANGUAGE=en_US:en
** [out :: *IP_HERE*] LOGNAME=root
** [out :: *IP_HERE*] SSH_CONNECTION=*IP_HERE* 53366 *IP_HERE* 22
** [out :: *IP_HERE*] _=/usr/bin/env
** [out :: *IP_HERE*] RUBY_VERSION=ruby-2.0.0-p247
** [out :: *IP_HERE*] GEM_HOME=/usr/local/rvm/gems/ruby-2.0.0-p247:/usr/local/rvm/gems/ruby-2.0.0-p247@global
** [out :: *IP_HERE*] BUNDLE_PATH=/usr/local/rvm/gems/ruby-2.0.0-p247

我发现此输出来自在gem( path_to_cap_gem/configuration/actions/inspect.rb )中定义的capture功能:

def capture(command, options={})
        output = ""
        invoke_command(command, options.merge(:once => true, :eof => !command.include?(sudo))) do |ch, stream, data|
          case stream
            when :out then output << data
            when :err then warn "[err :: #{ch[:server]}] #{data}"
            end
          end
        output
end

因此,函数parse_manifest尝试解析capture方法的此输出,而不是所需的输出。

完全奇怪的是,在/usr/games结尾的PATH字符串。

Gemfile的一部分:

gem 'capistrano'
gem 'rvm-capistrano'

上限文件:

load 'deploy'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks

deploy.rb:

require 'bundler/capistrano'
require 'rvm/capistrano'
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
set :application, 'dvr_rails'


set :rvm_ruby, "ruby-2.0.0-p247"
set :rvm_ruby_string, 'ruby-2.0.0-p247@dvr'
set :rvm_gem_home, "/usr/local/rvm/gems/#{fetch(:rvm_ruby)}"
set :rvm_ruby_path, "/usr/local/rvm/rubies/#{fetch(:rvm_ruby)}"
set :default_environment, {
        'RUBY_VERSION' => fetch(:rvm_ruby),
        'GEM_HOME' => "#{fetch(:rvm_gem_home)}:#{fetch(:rvm_gem_home)}@global",
        'BUNDLE_PATH' => fetch(:rvm_gem_home),
        'PATH' => "#{fetch(:rvm_gem_home)}/bin:#{fetch(:rvm_gem_home)}@global/bin:#{fetch(:rvm_ruby_path)}/bin:/home/rails/.rvm/bin:$PATH;",
}

set :rvm_type, :system  # Copy the exact line. I really mean :system here*

set :scm, :none
set :repository, '.'
set :deploy_via, :copy



server 'IP_HERE', :app, :web, :db, :primary => true

#If you are using Passenger mod_rails uncomment this:
namespace :deploy do
    task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
       run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
   end
end

set :deploy_to, '/var/sites/dvr_rails'

set :user, 'root'
set :use_sudo, 'true'
set :password, 'password'

有任何想法吗?

Ruby 2.0.0,Rails 4,Capistrano 2.15.5。 服务器-ubuntu 12.04,JS可执行文件-nodejs。

解决了。 仍然不知道capture功能深处到底发生了什么,但是编辑deploy.rb帮助。 这是我的工作配置:

require 'bundler/capistrano'
require 'rvm/capistrano'
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
set :application, 'dvr_rails'

set :rvm_ruby, "ruby-2.0.0-p247"
set :rvm_ruby_string, "ruby-2.0.0-p247@dvr"
set :rvm_gem_home, "/usr/local/rvm/gems/#{fetch(:rvm_ruby_string)}"

=begin
# These sets somehow messed up everything. 
set :rvm_ruby_path, "/usr/local/rvm/rubies/#{fetch(:rvm_ruby)}"
set :default_environment, {
        'RUBY_VERSION' => fetch(:rvm_ruby),
        'GEM_HOME' => "#{fetch(:rvm_gem_home)}:#{fetch(:rvm_gem_home)}@global",
        'BUNDLE_PATH' => fetch(:rvm_gem_home),
        'PATH' => "#{fetch(:rvm_gem_home)}/bin:#{fetch(:rvm_gem_home)}@global/bin:#{fetch(:rvm_ruby_path)}/bin:/home/rails/.rvm/bin;",
}
=end


#set :rvm_bin_path, "/usr/local/rvm/bin"
set :rvm_type, :system  # Copy the exact line. I really mean :system here*

set :scm, :none
set :repository, '.'
set :deploy_via, :copy

set :rails_env, 'production'


server 'IP_HERE', :app, :web, :db, :primary => true


#If you are using Passenger mod_rails uncomment this:
namespace :deploy do
    task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
       run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
   end
end

set :deploy_to, '/var/sites/dvr_rails'

set :user, 'root'
#set :use_sudo, 'true' #loggin as root, so no sudo required
set :password, 'password'

暂无
暂无

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

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