Skip to content

Commit 35a0075

Browse files
feat: add support for attach jvm debugger (#549)
Signed-off-by: Jeffrey Tang <[email protected]> Signed-off-by: JeffreyDallas <[email protected]> Co-authored-by: Jeromy Cannon <[email protected]>
1 parent 853eb9e commit 35a0075

10 files changed

+188
-20
lines changed

README.md.template

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,57 @@ You can find log for running solo command under the directory `~/.solo/logs/`
377377
The file `solo.log` contains the logs for the solo command.
378378
The file `hashgraph-sdk.log` contains the logs from solo client when sending transactions to network nodes.
379379

380+
## Using Intellj remote debug with solo
381+
382+
NOTE: the hedera-services path referenced '../hedera-services/hedera-node/data' may need to be updated based on what directory you are currently in. This also assumes that you have done an assemble/build and the directory contents are up-to-date.
383+
384+
Example 1: attach jvm debugger to a hedera node
385+
```bash
386+
./test/e2e/setup-e2e.sh
387+
solo node keys --gossip-keys --tls-keys
388+
solo network deploy -i node1,node2,node3 --debug-nodeid node2
389+
solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data
390+
solo node start -i node1,node2,node3 --debug-nodeid node2
391+
```
392+
393+
Once you see the following message, you can launch jvm debugger from Intellij
394+
```
395+
❯ Check all nodes are ACTIVE
396+
Check node: node1,
397+
Check node: node3, Please attach JVM debugger now.
398+
Check node: node4,
399+
```
400+
401+
Example 2: attach jvm debugger with node add operation
402+
403+
```bash
404+
./test/e2e/setup-e2e.sh
405+
solo node keys --gossip-keys --tls-keys
406+
solo network deploy -i node1,node2,node3 --pvcs
407+
solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data
408+
solo node start -i node1,node2,node3
409+
solo node add --gossip-keys --tls-keys --node-id node4 --debug-nodeid node4 --local-build-path ../hedera-services/hedera-node/data
410+
```
411+
412+
Example 3: attach jvm debugger with node update operation
413+
```bash
414+
./test/e2e/setup-e2e.sh
415+
solo node keys --gossip-keys --tls-keys
416+
solo network deploy -i node1,node2,node3
417+
solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data
418+
solo node start -i node1,node2,node3
419+
solo node update --node-id node2 --debug-nodeid node2 --local-build-path ../hedera-services/hedera-node/data --new-account-number 0.0.7 --gossip-public-key ./s-public-node2.pem --gossip-private-key ./s-private-node2.pem --agreement-public-key ./a-public-node2.pem --agreement-private-key ./a-private-node2.pem
420+
```
421+
422+
Example 4: attach jvm debugger with node delete operation
423+
```bash
424+
./test/e2e/setup-e2e.sh
425+
solo node keys --gossip-keys --tls-keys
426+
solo network deploy -i node1,node2,node3,node4
427+
solo node setup -i node1,node2,node3,node4 --local-build-path ../hedera-services/hedera-node/data
428+
solo node start -i node1,node2,node3,node4
429+
solo node delete --node-id node2 --debug-nodeid node3
430+
```
380431

381432
## Support
382433

src/commands/flags.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,17 @@ export const persistentVolumeClaims = {
745745
}
746746
}
747747

748+
/** @type {CommandFlag} **/
749+
export const debugNodeId = {
750+
constName: 'debugNodeId',
751+
name: 'debug-nodeid',
752+
definition: {
753+
describe: 'Enable default jvm debug port (5005) for the given node id',
754+
defaultValue: '',
755+
type: 'string'
756+
}
757+
}
758+
748759
/** @type {CommandFlag[]} **/
749760
export const allFlags = [
750761
accountId,
@@ -785,6 +796,7 @@ export const allFlags = [
785796
grpcEndpoints,
786797
hederaExplorerTlsHostName,
787798
hederaExplorerTlsLoadBalancerIp,
799+
debugNodeId,
788800
localBuildPath,
789801
log4j2Xml,
790802
namespace,

src/commands/network.mjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { constants, Templates } from '../core/index.mjs'
2525
import * as prompts from './prompts.mjs'
2626
import * as helpers from '../core/helpers.mjs'
2727
import path from 'path'
28-
import { validatePath } from '../core/helpers.mjs'
28+
import { addDebugOptions, validatePath } from '../core/helpers.mjs'
2929
import fs from 'fs'
3030

3131
export class NetworkCommand extends BaseCommand {
@@ -74,6 +74,7 @@ export class NetworkCommand extends BaseCommand {
7474
flags.fstChartVersion,
7575
flags.hederaExplorerTlsHostName,
7676
flags.hederaExplorerTlsLoadBalancerIp,
77+
flags.debugNodeId,
7778
flags.log4j2Xml,
7879
flags.namespace,
7980
flags.nodeIDs,
@@ -138,6 +139,17 @@ export class NetworkCommand extends BaseCommand {
138139
valuesArg += this.prepareValuesFiles(config.valuesFile)
139140
}
140141

142+
if (config.app !== constants.HEDERA_APP_NAME) {
143+
const index = config.nodeIds.length
144+
for (let i = 0; i < index; i++) {
145+
valuesArg += ` --set "hedera.nodes[${i}].root.extraEnv[0].name=JAVA_MAIN_CLASS"`
146+
valuesArg += ` --set "hedera.nodes[${i}].root.extraEnv[0].value=com.swirlds.platform.Browser"`
147+
}
148+
valuesArg = addDebugOptions(valuesArg, config.debugNodeId, 1)
149+
} else {
150+
valuesArg = addDebugOptions(valuesArg, config.debugNodeId)
151+
}
152+
141153
const profileName = this.configManager.getFlag(flags.profileName)
142154
this.profileValuesFile = await this.profileManager.prepareValuesForFstChart(profileName)
143155
if (this.profileValuesFile) {
@@ -182,6 +194,7 @@ export class NetworkCommand extends BaseCommand {
182194
flags.bootstrapProperties,
183195
flags.cacheDir,
184196
flags.chainId,
197+
flags.debugNodeId,
185198
flags.deployHederaExplorer,
186199
flags.deployMirrorNode,
187200
flags.hederaExplorerTlsLoadBalancerIp,

0 commit comments

Comments
 (0)