How can i debug the the docker container(storm crawler) which is written in java in vs code?

huangapple go评论148阅读模式
英文:

How can i debug the the docker container(storm crawler) which is written in java in vs code?

问题

我不知道如何调试运行在 Docker 容器中的 Storm Crawler,并且使用 VS Code 进行调试。我尝试查看了 https://code.visualstudio.com/docs/containers/debug-common 和其他 https://github.com/DigitalPebble/storm-crawler/wiki/Debug-with-Eclipse 的资源,但是没有找到关于如何配置针对相同情况的 launch.json 文件的任何信息。

是否有人可以指导我如何实现这一点?

英文:

I am unable to get how can i debug the docker container(which is running storm crawler) in the vs code? I tried looking for https://code.visualstudio.com/docs/containers/debug-common
and other https://github.com/DigitalPebble/storm-crawler/wiki/Debug-with-Eclipse.
But I did not anything, like how can i configure launch.json file for the same.

Can anyone guide me how can i do this?

答案1

得分: 0

如果您尝试使用由VSCode提供的Docker调试器,我认为您可能会遇到奇怪的问题。文档说明:

Docker扩展目前支持在Docker容器中调试Node.js、Python和.NET Core应用程序。

根据我的经验,编辑您的Java代码和Dockerfile,然后重新构建和重新运行容器可以帮助我编辑并检查代码是否存在任何问题。

Dockerhub也可能是寻求帮助的好地方。

英文:

If you are trying to use the Docker Debugger provided by VSCode, I think you will run into weird issues. The documentation states

> The Docker extension currently supports debugging Node.js, Python, and .NET Core applications within Docker containers.

In my experience, editing your Java code and Dockerfile, then rebuilding and rerunning the container helps me make edits and poke around my code for any issues.

Dockerhub may be a good place to search for help too

答案2

得分: 0

这为我解决了问题:
将launch.json文件编写为:

{
    "version": "0.2.0",
    "configurations": [
       {
           "type": "java",
           "name": "Debug (Attach) - Remote",
           "request": "attach",
           "hostName": "localhost",
           "port": 8000
       }
    ]
}

并将其连接到 storm crawler 的 Docker 容器,如下所示:

version: "3"

services:
  storm-jar:
    command: bash -c "storm kill crawler -w 0 ; storm local target/stormcrawler-1.0.jar org.apache.storm.flux.Flux es-crawler.flux --sleep 86400000" 
    environment:
      - STORM_JAR_JVM_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"
    ports:
      - 8000:8000

其中,在 storm crawler 的 GitHub 页面的 Wiki 页面上提供了用于调试 storm crawler 的环境设置:https://github.com/DigitalPebble/storm-crawler/wiki/Debug-with-Eclipse

英文:

This solves problem for me:
Writing launch.json file as :

{
    "version": "0.2.0",
    "configurations": [
       {
           "type": "java",
           "name": "Debug (Attach) - Remote",
           "request": "attach",
           "hostName": "localhost",
           "port": 8000,
       }
    ]
}

and connecting it to docker container of storm crawler as:

version: "3"

services:
  storm-jar:
    command: bash -c "storm kill crawler -w 0 ; storm local target/stormcrawler-1.0.jar org.apache.storm.flux.Flux es-crawler.flux --sleep 86400000" 
    environment:
      - STORM_JAR_JVM_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"
    ports:
      - 8000:8000

where enviroment to debug storm crawler has been provided on wiki page of github of storm crawler: https://github.com/DigitalPebble/storm-crawler/wiki/Debug-with-Eclipse

huangapple
  • 本文由 发表于 2020年10月1日 20:42:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/64155656.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定