1 Remote Debugging
Lex Berezhny edited this page 2018-03-08 19:46:28 -05:00

In PyCharm create a Python Remote Debugging run configuration, it provides some instructions on what to do next. Here is a more detailed version of the next steps:

  1. Upload pycharm-debug.egg from $PYCHARM_INSTALL_DIR/debug-eggs/pycharm-debug.egg up to the server.
  2. Modify the source you want to debug by adding code for connecting to the debug server:
    import sys
    sys.path.append('/PATH/TO/pycharm-debug.egg')
    import pydevd
    pydevd.settrace('localhost', port=1984)
    
    You can put this code anywhere in the project. It will act as the initial breakpoint and upon hitting this breakpoint it will try to connect to the debug server so that you can either continue stepping through code or continue the execution.
  3. In order for the app to be able to connect to your local PyCharm instance you need to setup an ssh tunnel; you do this from your local machine. Map the port in the code above (eg, 1984) to go into a tunnel and connect on the local port that the debugger is listening on (eg, 8000):
    ssh -R 1984:localhost:8000 lbry@54.236.53.10
    
  4. Last thing to do before debugging is to map the source directories between what they are on your local machine and on the remote server. This is so that as the debugger is stepping through the code you can actually see the code. You do this in the Python Remote Debug configuration in the Path mappings section.
  5. Set the port you want the debugger to listen on (eg, 8000).
  6. Once everything is setup and ready to go you want to start the debug server in PyCharm then after it's ready and listening for connections you can start the app on the server. Then just wait for the app to connect to PyCharm.