我们正在使用django Web框架构建我们的应用程序。 我们在申请中面临着这个非常关键的问题。我们正在尝试使用结构库连接到远程服务器。 通常从命令行我们可以连接到服务器。它也可以在内置的服务器中运行,它在django中从命令行运行。 命令
fab get_string -H user@10.10.10.10>>django.txt 2>&1
我们在apache中部署了代码,当应用程序在函数中遇到此命令时,应用程序会卡住。偶尔我们得到这些日志
"> Using fabfile 'C:\fabfile.py'
Commands to run: generic_task_linux_django
Parallel tasks now using pool size of 1
[user@10.10.10.10] Executing task 'generic_task_linux_django'
2012-08-30 09:36:15.805000
[user@10.10.10.10] run: /bin/bash -l -c "rm -rf /tmp//admin7"
Timed out trying to connect to 10.10.10.10 (attempt 1 of 1), giving up)
Fatal error: Timed out trying to connect to 10.10.10.10 (tried 1 time)
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\fabric-1.4.1-py2.7.egg\fabric\tasks.py", line 298, in execute
multiprocessing
File "C:\Python27\lib\site-packages\fabric-1.4.1-py2.7.egg\fabric\tasks.py", line 197, in _execute
return task.run(*args, **kwargs)
File "C:\Python27\lib\site-packages\fabric-1.4.1-py2.7.egg\fabric\tasks.py", line 112, in run
return self.wrapped(*args, **kwargs)
File "C:\fabfile.py", line 314, in generic_task_linux_django
run("rm -rf "+remote_path + '/' + local_dir_name)
File "C:\Python27\lib\site-packages\fabric-1.4.1-py2.7.egg\fabric\network.py", line 457, in host_prompting_wrapper
return func(*args, **kwargs)
File "C:\Python27\lib\site-packages\fabric-1.4.1-py2.7.egg\fabric\operations.py", line 905, in run
return _run_command(command, shell, pty, combine_stderr)
File "C:\Python27\lib\site-packages\fabric-1.4.1-py2.7.egg\fabric\operations.py", line 815, in _run_command
stdout, stderr, status = _execute(default_channel(), wrapped_command, pty,
File "C:\Python27\lib\site-packages\fabric-1.4.1-py2.7.egg\fabric\state.py", line 340, in default_channel
chan = connections[env.host_string].get_transport().open_session()
File "C:\Python27\lib\site-packages\fabric-1.4.1-py2.7.egg\fabric\network.py", line 84, in __getitem__
self.connect(key)
File "C:\Python27\lib\site-packages\fabric-1.4.1-py2.7.egg\fabric\network.py", line 76, in connect
self[key] = connect(user, host, port)
File "C:\Python27\lib\site-packages\fabric-1.4.1-py2.7.egg\fabric\network.py", line 393, in connect
raise NetworkError(msg, e)
NetworkError: Timed out trying to connect to 10.10.10.10 (tried 1 time)
Aborting."
因为它能够终止连接。但在大多数情况下它会卡住,我们没有任何日志可以显示。
然后我们决定将它作为Windows服务运行。我们使用附加的python文件为我们创建服务(recipe.py)。 我们再次遇到与我们面对的问题相同的问题。
答案 0 :(得分:1)
您可能希望查看您的连接是否因ssh凭据或类似问题而失败。如果您按照my suggestion here并让ssh / paramiko lib详细记录,您可以获得更多信息。