Debugging Crossbar.io app in IntelliJ

663 views Asked by At

I'm building an app using Crossbar.io in IntelliJ. Since you start the app using the crossbar start command in the shell I'm not clear on how to (ideally automatically) attach the Python debugger to the appropriate scripts. Anyone have any ideas?

1

There are 1 answers

3
Eddie On BEST ANSWER

Nice question.

I was a little bit confused about how to debug as well because it seems like crossbar is sort of mixing up python 2 and 3 together. I wanted to install crossbar.io under a virtual environment with Python 3 because the examples components are using python 3 but for some reason I could not manage to install crossbar under a virtual environment with Python 3 and Im forced to use Python 2 for WAMP routing instead. I normally use pyenv rather than virtualenv, however, I believe they both are similar. I ended up creating 2 pyenvs. One with Python 2.7.6 purely for crossbario router and the other with Python 3.4.2 for App Components.

My Solution

Have a look at the Screenshot

I don't know if it is the best way to solve this problem but this is what I did. I used PyCharm but I believe IntelliJ is similar as well.

I haven't tried this under virtualenv but I reckon it is quite similar.

  1. Install python 2.7.6 via pyenv

    $ pyenv install 2.7.6
    
  2. Create a pyenv with Python 2 for crossbar.io

    $ pyenv virtualenv 2.7.6 crossbar
    $ pyenv activate crossbar
    (crossbar)$ pip install crossbar
    
  3. Find and copy the full path for crossbar executable you have just installed.

    (crossbar)$ which crossbar
    

    and copy the path.

  4. Install python 3.4.2 via pyenv

    $ pyenv install 3.4.2
    
  5. Create a pyenv with Python 3 for app components

    $ pyenv virtualenv 3.4.2 app
    $ pyenv activate app
    (app)$ pip install autobahn
    
  6. Create a normal PyCharm project with "app" as a local python environment. I mean use python executable from app pyenv as an interpreter.

  7. Generate a hello world crossbar.io app.

    $ pyenv activate crossbar
    (crossbar)$ crossbar init --template hello:python
    
  8. From menubar go to Run/Edit configuration...

  9. Click a green + icon and select Python
  10. Paste the full path for crossbar executable script.
    ~/.pyenv/versions/crossbar/bin/crossbar
    
  11. put the word start as Script parameters.
  12. Make sure to select crossbar as a Python interpreter not app. Please correct me if Im wrong but I believe the interpreter we select here is only for running and debugging purpose not for code completion and stuffs.
  13. Make sure to put the path where .crossbar folder is located as a Working directory path.
  14. Visit 0.0.0.0:8080 to trigger the debug session.