【发布时间】:2015-03-20 10:43:27
【问题描述】:
我正在尝试将我在 Github 上的一个项目发布到 Digital Ocean 液滴上。我正在使用“部署 Rails 应用程序”一书中的 rails-server-template repo。我克隆了书中提到的骨架回购。然后,我按照快速入门的第 4 章和第 16 章(使用 Chef/Berkshelf 进行配置,使用 Capistrano 进行部署)并根据说明编辑了模板。
配置脚本运行良好,尽管它似乎在第一次尝试时挂起。在第二次尝试完成时没有任何问题。在检查了 Droplet IP 地址后,NGINX 服务器消息按预期出现,所以那里的东西似乎工作正常。
因此,在设置 capistrano 脚本并将它们指向我的存储库之后,我尝试运行 Capistrano 'deploy:setup_config' 命令,它在 Unicorn 设置过程之后(或可能在期间)立即爆炸。请看下面的错误信息(它只是错误信息出现前后的部分。
我希望得到任何关于我可以尝试的事情的提示,或者如果从错误消息中可以清楚地看出问题可能是什么?我用一些额外的调试和跟踪选项运行了“deploy:setup_config”,但我仍然不知道是什么导致 capistrano 中止。我花了几个小时搜索和阅读来自 Google 搜索的类似消息,但我没有尝试过。对于我部署大脑的菜鸟来说,这似乎是一个 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
部署.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
【问题讨论】:
标签: ruby ruby-on-rails-3 deployment digital-ocean capistrano3