Tuesday, March 22, 2016

How to call ElasticSearch in debug mode, ElasticSearch 2.2 starts in debug mode, active debug mode in ElasticSearch, bat file add debug mode parameter, How add debug in batch file, How to debug elasticsearch plugin using eclipse



Inside bat file, from where you are calling ElasticSearch (In my case E:\Software\elasticsearch-2.2.1\bin\elasticsearch.bat) add these parameter

-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8010

Then go to Eclipse and in Remote Debug put port 8010 for your ElasticSearch Plugin Code.

Here is full bat file to call ElasticSearch:

@echo off

SETLOCAL enabledelayedexpansion
TITLE Elasticsearch 2.2.1

SET params='%*'

:loop
FOR /F "usebackq tokens=1* delims= " %%A IN (!params!) DO (
    SET current=%%A
    SET params='%%B'
SET silent=N

IF "!current!" == "-s" (
SET silent=Y
)
IF "!current!" == "--silent" (
SET silent=Y
)

IF "!silent!" == "Y" (
SET nopauseonerror=Y
) ELSE (
   IF "x!newparams!" NEQ "x" (
       SET newparams=!newparams! !current!
        ) ELSE (
            SET newparams=!current!
        )
)

    IF "x!params!" NEQ "x" (
GOTO loop
)
)

SET HOSTNAME=%COMPUTERNAME%

CALL "%~dp0elasticsearch.in.bat"
IF ERRORLEVEL 1 (
IF NOT DEFINED nopauseonerror (
PAUSE
)
EXIT /B %ERRORLEVEL%
)

"%JAVA_HOME%\bin\java"  -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8010 %JAVA_OPTS% %ES_JAVA_OPTS% %ES_PARAMS% -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" start !newparams!

ENDLOCAL

1 comment:

  1. This is indeed a good finding. Thanks for the post.

    ReplyDelete

You can put your comments here (Either feedback or your Question related to blog)