net-scp等待,直到在capistrano的git:wrapper任务中超时 [英] net-scp waiting until time-out in capistrano's git:wrapper task

查看:79
本文介绍了net-scp等待,直到在capistrano的git:wrapper任务中超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Capistrano 3.0.1部署使用Rails 3.2和Ruby 2.1,并且遇到git:check任务的问题:

I'm using Rails 3.2 and Ruby 2.1 with capistrano 3.0.1 deployement, and I'm facing issue with the git:check task :

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

ruby​​调试器给出的最后一行代码大约是 await_response_state ,所以我猜ssh-kit无法得到答案并超时。我不知道为什么为什么

The last line of code that the ruby debugger gave is about await_response_state, so I guess that ssh-kit doesn't get an answer and timed out. I can't figure why though ???

我挖了 /home/douglas/.rvm/gems/ruby-2.1 .0 @ rails3 / gems / capistrano-3.0.1 / lib / capistrano / tasks / git.rake ,并在第13行中找到了这个:

I dug into /home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/capistrano-3.0.1/lib/capistrano/tasks/git.rake and found this at the stucked line 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"

对于我来说,此命令的参数就像中文一样,我无法对其进行更深入的研究。

The parameters for this command are like chinese for me and I can't dig deeper.

如果有人可以在此问题上为我提供帮助(使用capistrano或bash&

If anybody could help me on this issue (either with capistrano, or with bash & ruby for the parameters) I would be gratefull.

谢谢

推荐答案

好,我找到了解决方案。

Ok I found the solution.

Capistrano使用ssh连接到我的服务器。

Capistrano use ssh to connect to my server.

尽管大多数人会告诉您,当您以非登录和非交互式外壳(使用ssh中的脚本)连接时不会执行任何文件

Though most people would tell you that when you connect as non-login and non-interactive shell (with a script in ssh) no file will be executed :

我检查了那个人Bash的页面,并发现了这个有趣的部分:

I checked the man page of Bash and found this interesting part :


Bash尝试确定何时在连接其标准
输入的情况下运行它网络连接,好像是由远程shell
守护程序(通常是rshd,)或安全shell守护程序sshd一样。如果bash
确定它是以这种方式运行的,它将从〜/ .bashrc中读取并执行
命令(如果该文件存在并且可读)。

不会这样做如果作为sh调用则为this。 --norc选项可用于禁止
禁止这种行为,而--rcfile选项可用于强制
读取另一个文件,但rshd通常不调用shell

Bash attempts to determine when it is being run with its standard input connected to a a network connection, as if by the remote shell daemon, usually rshd, or the secure shell daemon sshd. If bash determines it is being run in this fashion, it reads and executes commands from ~/.bashrc, if that file exists and is readable. It will not do this if invoked as sh. The --norc option may be used to inhibit this behavior, and the --rcfile option may be used to force another file to be read, but rshd does not generally invoke the shell with those options or allow them to be specified.

所以我检查了我的〜/ .bashrc 文件并意识到我放了一些echo命令来检查不同的环境变量。没什么害处...。乍看之下。

So I checked my ~/.bashrc file and realize I put some echo commands to check different environnment variable. Nothing harmfull.... at first glance.

我设法在bash上单独测试了scp命令,但失败了。这很奇怪,因为它在过去的某个时候起作用。我在Google中搜索了
,发现了一个类似的问题: SCP已被窃听。当您的.bashrc输出一些echo命令时,它就会搞砸了。

I managed to test scp command solo on the bash and it was failing. That was weird because it was working at some point in the past. I searched in google and found a similar issue : SCP is bugged. When your .bashrc output some echo command, it get screwed up.

我所有问题的原因都来自于 scp中的错误,不会由开发人员修复。在我的情况下,这很不幸。

The cause of all my problems was coming from a bug in scp that is not going to be fixed by the developers. This is unfortunate in my case.

这里是其他人针对类似问题的查询:https://unix.stackexchange.com/questions/18231/scp-fails-without-error
这是可追溯到2000年的SCP错误! https:// bugzilla。 redhat.com/show_bug.cgi?id=20527

Here it is an inquiry made by someone else on a similar problem : https://unix.stackexchange.com/questions/18231/scp-fails-without-error And here it is the SCP bug dating from year 2000 !!! https://bugzilla.redhat.com/show_bug.cgi?id=20527

要解决此问题,我在<$ c $开头注释了我的 echo命令 c>〜/ .bashrc 文件:

To solve it, I commented my "echo commands" at the beginning of my ~/.bashrc file :

# ~/.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 ==='

这篇关于net-scp等待,直到在capistrano的git:wrapper任务中超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆