Skip to content

Latest commit

 

History

History
287 lines (222 loc) · 6.22 KB

File metadata and controls

287 lines (222 loc) · 6.22 KB

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import useBaseUrl from '@docusaurus/useBaseUrl';

Remote Debugging

Supported IDEs

Language IDE Edition Required Plugin
Java IntelliJ IDEA Ultimate N/A
Go IntelliJ IDEA Ultimate Go plugin
GoLand Professional N/A
Python IntelliJ IDEA Ultimate Python plugin
PyCharm Professional N/A
PHP IntelliJ IDEA Ultimate PHP plugin
PHPStorm Professional N/A
Node.js IntelliJ IDEA Ultimate N/A
WebStrom Professional N/A

:::danger ISSUES

Debugging feature has issue with Kind

:::

Debugging Process

  1. Select the workload that you want to debug
  2. Right-click the workload and select Dev Config, configure your debugging configuration
  3. Then right-click this workload again and select Remote Debug
  4. Nocalhost will automatically enter the DevMode and start remote debugging
<iframe width="100%" height="600" src="//player.bilibili.com/player.html?aid=378208000&bvid=BV12f4y1w7EX&cid=415232277&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>

Debugging Configurations in IDE

Before entering debug mode, if you do not have a Nocalhost IDE debug configuration under an existing workload, Nocalhost will create a new IDE debug configuration according to your Nocalhost configuration. Different IDE has different configuration names and templates.

:::tip Multi Configs

If you already have a Nocalhost IDE debug configuration under the existing workload, Nocalhost will use the first one to start debugging. You can change the order in the Run/Debug Configurations window within IDE.

Nocalhost debugging configurations in IDE

:::

Configuration

The development environment is different between developers. You should configure remote debug configurations according to the actual situation.

Sample Configuration

<Tabs defaultValue="java" values={[ {label: 'Java', value: 'java'}, {label: 'Python', value: 'python'}, {label: 'Go', value: 'go'}, {label: 'PHP', value: 'php'}, {label: 'Node.js', value: 'node'}, ]}>

name: java-remote-debugging
serviceType: deployment
containers:
  - name: ""
    dev:
        ...
        command:
          debug:
            - ./debug.sh
        debug:
          remoteDebugPort: 5005
        ...

Maven Example

The shell command for Maven example:

 mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"

For jdk <=1.7 you should replace -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 with -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005

For lower version of the springBoot you should replace -Drun.jvmArguments with -Dspring-boot.run.jvmArguments

Gradle Example

The startup command for Gradle example:

./gradlew bootRun --debug-jvm --no-daemon
name: python-remote-debugging
serviceType: deployment
containers:
  - name: ""
    dev:
        ...
        command:
          debug:
            - ./debug.sh
        debug:
          remoteDebugPort: 9009
        ...
#! /bin/sh

pip3 install --no-cache-dir -r ./requirements.txt

export DEBUG_DEV=0
export FLASK_DEBUG=0
export FLASK_ENV=development

flask run --host=0.0.0.0 --port=9999

How does it Works?

Nocalhost using pydevd to debug Python application.

Principle of Remote Python Debugging
name: go-remote-debugging
serviceType: deployment
containers:
  - name: ""
    dev:
        ...
        command:
          debug:
            - ./debug.sh
        debug:
          remoteDebugPort: 9009
        ...
#! /bin/sh

export GOPROXY=https://goproxy.cn
dlv --headless --log --listen :9009 --api-version 2 --accept-multiclient debug app.go
name: php-remote-debugging
serviceType: deployment
containers:
  - name: ""
    dev:
        ...
        command:
          debug:
            - ./debug.sh
        debug:
          remoteDebugPort: 9003
        ...
#!/bin/sh

php -t ./ -S 0.0.0.0:9999;

How does it works?

Nocalhost using Xdebug to debug PHP applications.

Principle of Remote PHP Debugging
name: nodejs-remote-debugging
serviceType: deployment
containers:
  - name: ""
    dev:
        ...
        command:
          debug:
            - ./debug.sh
        debug:
          remoteDebugPort: 9229
        ...
#!/bin/sh

npm install
node --inspect=0.0.0.0:9229 ./index.js