Joh*_*n Q 11 python django remote-debugging
基础:
我使用"远程调试"配置文件在本地启动pycharm,它看起来很好.
Starting debug server at port 4000
Use the following code to connect to the debugger:
import pydevd
pydevd.settrace('<my local machines public ip addr>', port=4000, suspend=False)
Waiting for connection...
Run Code Online (Sandbox Code Playgroud)在远程服务器上,我对pycharm-debug.egg进行了适当的调用__init__.py(但我也尝试将它放在代码中的其他位置).
我启动这样的远程服务器,python manage.py runserver <remote domain name>:8000并在本地pycharm IDE /调试器上看到:
"Connected to pydev debugger (build 133.1347)"
Run Code Online (Sandbox Code Playgroud)在此之后,事情只是坐在那里......我没有得到关于执行地点的任何反馈,并且pycharm IDE中没有能力"启动/继续/运行"任何东西.
在远程服务器上,如果我<ctrl-c>,我看到:
File "/<path here>/pycharm-debug.egg/pydevd.py", line 1256, in settrace
File "/<path here>/pycharm-debug.egg/pydevd.py", line 1305, in _locked_settrace
Run Code Online (Sandbox Code Playgroud)我的猜测是一切都正常连接,但我没有看到一种方法来启动所有运行.我有"暂停=假",所以我原本预计它会开始.当我尝试针对远程服务器启动页面时,我得到"未连接",因此Web服务器显然还没有运行(如果curl http://<remote server domain>:8000我得到的话curl: (7) Failed connect to <remote server domain>:8000; Connection refused).如果没有远程调试,这可以在我的本地开发机器或远程服务器上正常运行.
我究竟做错了什么?:) 谢谢!
细节:
在运行代码/进程的远程服务器上,我想在main中调试__init__.py我有:
import os
import sys
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
sys.path.append(BASE_DIR + '/pycharm-debug.egg')
import pydevd
pydevd.settrace('<my local machines public ip addr>', port=4000, suspend=False)
Run Code Online (Sandbox Code Playgroud)本地pycharm IDE显示:
Starting debug server at port 4000
Use the following code to connect to the debugger:
import pydevd
pydevd.settrace('localhost', port=4000, suspend=False) (tried with <public ip addr> for this, too.
Waiting for connection...
---- and then, after I start the remote server process: ----
Connected to pydev debugger (build 133.1347)
Run Code Online (Sandbox Code Playgroud)其他说明:
我不知道如何"碰撞"任何东西让事情运行,让我开始调试.
感谢您的帮助.
对于未来的googlers ...我能够远程调试工作,但不能通过这种方法.我刚刚在pycharm论坛上回答了类似的问题,所以我想我会用适合我的方法更新这个问题.
/usr/local/bin/python)./home/<username>/.pycharm_helpers- 我不记得这是否是自动创建的).转到"运行/编辑配置..."并添加"Django Server"(对话框左上角的加号).
DJANGO_SETTINGS_MODULE = <app>/settings.py).为了我的目的,我也需要设置HTTPS=1./home/<username>/<xyz>/<appdir>).设置从本地目录到远程目录的路径映射(即/Users/JohnQ/<xyz>/<appdir>=/home/<username>/<xyz>/<appdir>).
因为我需要其他第三方服务器(比如FB等)能够使用HTTPS命中这个服务器,所以我在远程服务器上使用了"stunnel" - 它很容易设置).
除此之外,一个方便的事情是设置部署确认,以便您可以右键单击以上载文件的较新版本(在"工具/部署/配置..."下).
/"对我来说只是" ".创建它之后,您应该只需右键单击任何文件/目录并选择"上传到...".请注意,对于初始上载,我只是将tar.gz scp到我的服务器以节省时间,我只通过部署配置上传我在调试期间所做的更改.我一直很乐意使用它来进行~4 mos的远程调试,所以它工作正常.
对我来说,删除suspend=False参数就可以了。
文档说@param suspend: whether a breakpoint should be emulated as soon as this function is called.。
如果你让它在那里,它就会连接,但不考虑断点。然后你基本上应该使用另一个pydevd.settrace('ip.addr')->注意不suspend
| 归档时间: |
|
| 查看次数: |
10459 次 |
| 最近记录: |