Start a local development cluster by following the steps in Setting up your Service Fabric development environment.
Update entryPoint.sh of the service you wish to debug, so that it starts the java process with remote debug parameters. This file can be found at the following location:
ApplicationName\ServiceNamePkg\Code\entrypoint.sh. Port 8001 is set for debugging in this example.
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=y -Djava.library.path=$LD_LIBRARY_PATH -jar myapp.jar
Update the Application Manifest by setting the instance count or the replica count for the service that is being debugged to 1. This setting avoids conflicts for the port that is used for debugging. For example, for stateless services, set
InstanceCount="1"and for stateful services set the target and min replica set sizes to 1 as follows:
Deploy the application.
In the Eclipse IDE, select Run -> Debug Configurations -> Remote Java Application and input connection properties and set the properties as follows:
Host: ipaddress Port: 8001
- Set breakpoints at desired points and debug the application.
If the application is crashing, you may also want to enable coredumps. Execute
ulimit -c in a shell and if it returns 0, then coredumps are not enabled. To enable unlimited coredumps, execute the following command:
ulimit -c unlimited. You can also verify the status using the command
ulimit -a. If you wanted to update the coredump generation path, execute
echo '/tmp/core_%e.%p' | sudo tee /proc/sys/kernel/core_pattern.