Dou*_*las 0 capistrano ruby-on-rails-3.2
我正在使用Rails 3.2和Ruby 2.1以及capistrano 3.0.1 deployement,我面临着git:check任务的问题:
douglas@bilbo:/var/www/odpf$ cap production git:check --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
INFO [01658950] Running /usr/bin/env mkdir -p /tmp/odpf/ on phisa-odpf-vd.vserver.nimag.net
DEBUG [01658950] Command: /usr/bin/env mkdir -p /tmp/odpf/
DEBUG [01658950] === Lancement de /home/rvm_admin/.bashrc ===
INFO [01658950] Finished in 0.629 seconds with exit status 0 (successful).
cap aborted!
=== Lancement de /home/rvm_admin/.bashrc ===
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-scp-1.1.2/lib/net/scp.rb:392:in `await_response_state'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-scp-1.1.2/lib/net/scp.rb:363:in `block (3 levels) in start_command'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:311:in `call'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:311:in `process'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:222:in `block in preprocess'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:222:in `each'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:222:in `preprocess'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-scp-1.1.2/lib/net/scp.rb:279:in `upload!'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:81:in `upload!'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/capistrano-3.0.1/lib/capistrano/tasks/git.rake:14:in `block (3 levels) in <top (required)>'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => git:check => git:wrapper
Run Code Online (Sandbox Code Playgroud)
ruby调试器给出的最后一行代码是关于的await_response_state,所以我猜ssh-kit没有得到答案并且超时.我想不出为什么虽然???
我挖了进去/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/capistrano-3.0.1/lib/capistrano/tasks/git.rake,发现这是在13号线:
upload! StringIO.new("#!/bin/sh -e\nexec /usr/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no \"$@\"\n"), "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
Run Code Online (Sandbox Code Playgroud)
这个命令的参数对我来说就像中文,我不能深入挖掘.
如果有人可以在这个问题上帮助我(无论是使用capistrano,还是使用bash和ruby作为参数),我将不胜感激.
谢谢
好的,我找到了解决方案.
Capistrano使用ssh连接到我的服务器.
虽然大多数人会告诉你,当你作为非登录和非交互式shell(在ssh中使用脚本)连接时,不会执行任何文件:
这并非总是如此 !
我检查了Bash的手册页,发现了这个有趣的部分:
Bash尝试确定何时将其标准输入连接到网络连接,就像远程shell守护程序(通常是rshd)或安全shell守护程序sshd一样.如果bash确定它以这种方式运行,它将从〜/ .bashrc读取并执行命令,如果该文件存在且可读的话.如果作为sh调用它将不会这样做.--norc选项可用于禁止此行为,并且--rcfile选项可用于强制读取另一个文件,但rshd通常不会使用这些选项调用shell或允许指定它们.
所以我检查了我的~/.bashrc文件并意识到我放了一些echo命令来检查不同的环境变量.没什么有害的....乍一看.
我设法在bash上测试scp命令solo并且它失败了.这很奇怪,因为它在过去的某个时刻正在发挥作用.我在谷歌搜索并发现了类似的问题:SCP被窃听.当你的.bashrc输出一些echo命令时,它就搞砸了.
我所有问题的原因都来自scp中的一个错误,开发人员不会修复它.在我的情况下,这是不幸的.
这是其他人对类似问题的调查:https://unix.stackexchange.com/questions/18231/scp-fails-without-error 这里是2000年以来 的SCP漏洞!https://bugzilla.redhat.com/show_bug.cgi?id=20527
为了解决这个问题,我在~/.bashrc文件开头评论了我的"echo命令" :
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
#
# These are my echo command checks
#echo '=== Execution of /home/rvm_admin/.bashrc ==='
#[[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
#shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'#echo "Agent forwarding ? => SSH_AUTH_SOCK = $SSH_AUTH_SOCK"
#echo '=== End of echo commands by Douglas ==='
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1219 次 |
| 最近记录: |