Remotely Debugging a Teranode Operator
For advanced users who need to debug a running Teranode operator, follow these steps:
- Edit the Cluster Custom Resource (CR):
Use the following command, replacing
mainnet-1with your namespace if different:
kubectl edit clusters.teranode.bsvblockchain.org -n mainnet-1 mainnet-1
- Modify the Service Configuration:
Find the service you want to debug (e.g., legacy) and override the
commandkey underdeploymentOverrides:
command:
- ./dlv
- --listen=:4040
- --continue
- --accept-multiclient
- --headless=true
- --api-version=2
- exec
- ./teranode.run
- --
Note: If you need to debug multiple services, add this command to all necessary services.
- Port Forward the Debugger: You have two options:
a. Using kubectl (easier for a single port):
kubectl port-forward -n mainnet-1 <replace_with_pod_name> 4040:4040
b. Using kubefwd (useful for multiple services):
sudo kubefwd svc -n mainnet-1
- Connect Your IDE/Debugger:
Teranode uses Delve (dlv) as its debugger. You can connect using any IDE or tool that supports Delve:
VS Code:
- Install the Go extension
- Configure a remote attach configuration in your
launch.json - See the VS Code Go debugging guide for detailed setup
GoLand:
- Use "Go Remote" run configuration
- See the GoLand remote debugging guide
Delve CLI:
- Connect directly using the command line:
dlv connect localhost:4040
Important Notes:
- If using Cursor IDE (VS Code fork), be aware it may cause connection issues with the debugger
-
If using kubefwd, ensure your debugger IP points to the correct service (e.g., use
asset:4040for the asset service) -
Start Debugging:
- Add breakpoints as needed.
- Begin your debugging session.
Note: When debugging multiple services, make sure to use the correct local DNS (e.g., asset:4040) for each service you're debugging.