Capistrano在部署期间中止:使用SSHKit :: Runner :: ExecuteError进行设置:

时间:2015-03-20 10:43:28

标签: ruby ruby-on-rails-3 deployment digital-ocean capistrano3

我正在尝试将我在Github上的一个项目启动到Digital Ocean Droplet上。我正在使用“部署Rails应用程序”一书中的rails-server-template repo。我按照书中提到的克隆了骨架回购。然后我按照快速入门第4章和第16章(使用Chef / Berkshelf进行配置,并使用Capistrano进行部署)并按照说明编辑模板。

配置脚本运行得很好,虽然它似乎在第一次尝试时挂起。第二次尝试完成没有任何问题。检查Droplet IP地址后,NGINX服务器消息按预期显示,因此事情似乎正常。

因此,在设置了capistrano脚本并将它们指向我的仓库后,我尝试运行Capistrano的deploy:setup_config'命令,它在Unicorn设置程序之后(或可能在此期间)爆炸。请参阅下面的错误消息(它只是出现错误消息之前和之后的部分。

我会喜欢我可以尝试的任何提示,或者从错误信息中可以清楚地知道问题可能是什么?我使用一些额外的调试和跟踪选项运行'deploy:setup_config',但我仍然不知道导致capistrano中止的原因。我花了几个小时搜索和阅读来自谷歌搜索的类似消息,但我没有尝试过任何工作。对于我的部署大脑的菜鸟,它似乎是一个SSH问题。所以我甚至确保我有ssh代理转发设置,现在看起来我(我最初没有),但错误继续停止操作,即使在修复后。

==以下错误消息:

DEBUG [b9208e5b] Command: ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 /usr/bin/env chmod +x /home/deploy/apps/shared/config/unicorn_init.sh )
D, [2015-03-19T03:04:56.581563 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: queueing packet nr 77 type 90 len 44
D, [2015-03-19T03:04:56.581839 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: sent 120 bytes
D, [2015-03-19T03:04:56.600361 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: read 52 bytes
D, [2015-03-19T03:04:56.600635 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: received packet nr 91 type 91 len 28
I, [2015-03-19T03:04:56.600775 #10311] INFO -- net.ssh.connection.session[3fcae950b3bc]: channel_open_confirmation: 10 0 0 32768
I, [2015-03-19T03:04:56.601065 #10311] INFO -- net.ssh.connection.channel[3fcae98a9d84]: sending channel request "env"
D, [2015-03-19T03:04:56.601241 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: queueing packet nr 78 type 98 len 44
I, [2015-03-19T03:04:56.601552 #10311] INFO -- net.ssh.connection.channel[3fcae98a9d84]: sending channel request "exec"
D, [2015-03-19T03:04:56.601712 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: queueing packet nr 79 type 98 len 156
D, [2015-03-19T03:04:56.601891 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: sent 248 bytes
D, [2015-03-19T03:04:56.619705 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: read 88 bytes
D, [2015-03-19T03:04:56.620077 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: received packet nr 92 type 93 len 28
I, [2015-03-19T03:04:56.620336 #10311] INFO -- net.ssh.connection.session[3fcae950b3bc]: channel_window_adjust: 10 +2097152
D, [2015-03-19T03:04:56.620778 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: received packet nr 93 type 99 len 12
I, [2015-03-19T03:04:56.621003 #10311] INFO -- net.ssh.connection.session[3fcae950b3bc]: channel_success: 10
D, [2015-03-19T03:04:56.623588 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: read 140 bytes
D, [2015-03-19T03:04:56.624133 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: received packet nr 94 type 98 len 44
I, [2015-03-19T03:04:56.624377 #10311] INFO -- net.ssh.connection.session[3fcae950b3bc]: channel_request: 10 exit-status false
D, [2015-03-19T03:04:56.624593 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: received packet nr 95 type 96 len 12
I, [2015-03-19T03:04:56.624688 #10311] INFO -- net.ssh.connection.session[3fcae950b3bc]: channel_eof: 10
D, [2015-03-19T03:04:56.624819 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: received packet nr 96 type 97 len 12
I, [2015-03-19T03:04:56.624890 #10311] INFO -- net.ssh.connection.session[3fcae950b3bc]: channel_close: 10
D, [2015-03-19T03:04:56.625106 #10311] DEBUG -- tcpsocket[3fcae8adb5e0]: queueing packet nr 80 type 97 len 28
INFO [b9208e5b] Finished in 0.044 seconds with exit status 0 (successful).
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@104.131.156.16: no implicit conversion of nil into String
/Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in rescue in block (2 levels) in execute' /Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:inblock (2 levels) in execute'
TypeError: no implicit conversion of nil into String
/Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capistrano-cookbook-0.2.1/lib/capistrano/cookbook/helpers/substitute_strings.rb:9:in gsub!' /Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capistrano-cookbook-0.2.1/lib/capistrano/cookbook/helpers/substitute_strings.rb:9:inblock in sub_strings'
/Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capistrano-cookbook-0.2.1/lib/capistrano/cookbook/helpers/substitute_strings.rb:8:in each' /Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capistrano-cookbook-0.2.1/lib/capistrano/cookbook/helpers/substitute_strings.rb:8:insub_strings'
/Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capistrano-cookbook-0.2.1/lib/capistrano/cookbook/tasks/setup_config.cap:29:in block (4 levels) in <top (required)>' /Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capistrano-cookbook-0.2.1/lib/capistrano/cookbook/tasks/setup_config.cap:28:ineach'
/Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capistrano-cookbook-0.2.1/lib/capistrano/cookbook/tasks/setup_config.cap:28:in block (3 levels) in <top (required)>' /Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:ininstance_exec'
/Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in run' /Users/jose8a/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:13:inblock (2 levels) in execute'
Tasks: TOP => deploy:setup_config

deploy.rb:

lock '3.4.0'
set :log_level, :debug 

set :application, 'yojobs'
set :deploy_user, 'deploy'

set :ssh_options, { :forward_agent => true}
set :ssh_options, { verbose: :debug }

#setup repo details
set :scm, :git
set :repo_url, 'git@github.com/jose8a/yojobs.git'

# setup rvm
set :rbenv_type, :system
set :rbenv_ruby, '2.1.2'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}

# how many old releases do we want to keep, not much
set :keep_releases, 5

# files we want symlinking to specific entries in shared
set :linked_files, %w{config/database.yml config/secrets.yml}

# dirs we want symlinking to shared
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# this:
# http://www.capistranorb.com/documentation/getting-started/flow/
# is worth reading for a quick overview of what tasks are called
# and when for `cap stage deploy`

namespace :deploy do
end

production.rb(注意:我在这里屏蔽了实际的IP地址):

set :stage, :production
set :branch, "master"

# This is used in the Nginx VirtualHost to specify which domains
# the app should appear on. If you don't yet have DNS setup, you'll 
# need to create entries in your local Hosts file for testing.
set :server_name, 'MY.IP.ADDR.ESS'

# used in case we're deploying multiple versions of the same app
# side by side. Also provides quick sanity checks when looking at
# filepaths
set :full_path_name, "#{fetch(:application)}_#{fetch(:stage)}"

server 'MY.IP.ADDR.ESS', user: 'deploy', roles: %w{web app db}, primary: true

set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}"

# don't try to infer something as important as environment from stage name
set :rails_env, :production

# number of unicorn workers, this will be reflected in 
# the unicorn.rb and the monit configs
set :unicorn_worker_count, 5

# wether we're using ssl or not, used for building nginx
# config file
set :enable_ssl, false

2 个答案:

答案 0 :(得分:0)

尝试在没有rbenv的情况下运行安装程序(从Capfile和deploy.rb中删除它)

答案 1 :(得分:0)

我有一个类似的案例,但我的问题是环境变量(当我开始使用全新的笔记本电脑时)。 我有以下

set :ssh_options,
   forward_agent: true,
   auth_methods: ['publickey'],
   keys: [ENV['RSA_PUB']]

在这台新笔记本电脑中,我从未设置过 RSA_PUB