【问题标题】:connecting to remote server using fabric library in django使用 django 中的结构库连接到远程服务器
【发布时间】:2012-09-07 00:55:28
【问题描述】:

我们正在使用 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)。 我们再次面临与 apache 相同的问题。

【问题讨论】:

    标签: django apache fabric


    【解决方案1】:

    您可能想查看您的连接是否由于 ssh 凭据或类似原因而失败。如果您关注my suggestion here 并详细记录 ssh/paramiko 库,您可以获得更多信息。

    【讨论】:

      猜你喜欢
      • 2012-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-01
      • 1970-01-01
      • 2016-08-03
      相关资源
      最近更新 更多