Skip to content

Instantly share code, notes, and snippets.

@jconwell
Created July 14, 2015 23:25
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jconwell/1af41535c5ecd2f4a9dd to your computer and use it in GitHub Desktop.
Save jconwell/1af41535c5ecd2f4a9dd to your computer and use it in GitHub Desktop.
Remotly Debug ElasticSearch in IntelliJ
Pretty simple once you know how.
Step 1: In IntelliJ, create a new remote debug configuration. Name it something ElasticSearchy. All of the default values should be fine. The only thing you need to change is the Host value. If ElasticSearch is gonna be running locally, just use "localhost", otherwise use the IP address of the remote machine ElasticSearch is gonna run on
Step 2: When starting ElasticSearch, just add a -D argument with the standard java remote debug values like so:
bin/elasticsearch -D "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
ElasticSearch will start and if suspend is set to 'y', it'll pause execution until you have attached the IntelliJ debugger.
Step 3: In IntilliJ, run the remote debug configuration you created in step 1.
At this point any breakpoints you have set in, say, an ElasticSearch plugin will get hit
@nikita-rastogi
Copy link

@elbarto93 , setting ES_JAVA_OPTS did not work because the value is getting set by groovy script, hence it is getting over written.
https://github.com/elastic/elasticsearch/blob/b3f3a4312b55acd02e9291d7ae231b397e275d0b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy#L627
i changed the port at this line and then from commandline ran ./gradlew run --debug-jvm, then the port was 5005 instead of 8000

Thanks
Nikita

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment