英文:
How to show app's original logs while using delve debugger with kubernetes and golang?
问题
你可以通过查看容器的日志来了解为什么 waiter-service 在其他服务可以正常工作时无法正常工作。在Kubernetes中,你可以使用以下命令来获取容器的日志:
kubectl logs <pod_name> -c <container_name>
其中 <pod_name>
是你的Pod的名称,<container_name>
是你的容器的名称(在你的情况下可能是 waiter-service
)。这将返回该容器的日志输出。
另外,你还可以使用以下命令来获取Pod的名称和容器的名称:
kubectl get pods
这将列出所有正在运行的Pod及其相关信息,包括名称和容器名称。
通过查看容器的日志,你可以找到导致 waiter-service 无法正常工作的原因。可能会有错误消息或异常堆栈跟踪,可以帮助你诊断问题并采取相应的措施。
英文:
I'm using Kubernetes and helm chart to deploy some microservice applications in a system.
Other services will use Netcat to wait for the waiter-service until it is up, but this waiter-service service seems not to work properly when started by delve, so I want to check its logs.
The dockerfile's entry point is like below:
/dlv --listen=:40000 --log --log-output=rpc --allow-non-terminal-interactive=true
--api-version=2 exec /server -- appname --config=configfile.yaml
The logs i received are like below:
2022-08-24T13:22:11Z debug layer=rpc serving JSON-RPC on new connection
2022-08-24T13:22:11Z debug layer=rpc <- RPCServer.SetApiVersion(api.SetAPIVersionIn{"APIVersion":2})
2022-08-24T13:22:11Z debug layer=rpc -> *api.SetAPIVersionOut{} error: ""
2022-08-24T13:22:11Z debug layer=rpc <- RPCServer.IsMulticlient(rpc2.IsMulticlientIn{})
2022-08-24T13:22:11Z debug layer=rpc -> *rpc2.IsMulticlientOut{"IsMulticlient":false} error: ""
2022-08-24T13:22:11Z debug layer=rpc (async 3) <- RPCServer.State(rpc2.StateIn{"NonBlocking":true})
2022-08-24T13:22:11Z debug layer=rpc (async 3) -> rpc2.StateOut{"State":{"Pid":14,"Running":false,"Recording":false,"CoreDumping":false,"currentThread":{"id":14,"pc":4652512,"file":"/usr/lib/go-1.18/src/runtime/rt0_linux_amd64.s","line":8,"function":{"name":"_rt0_amd64_linux","value":4652512,"type":0,"goType":0,"optimized":true},"goroutineID":0,"ReturnValues":null,"CallReturn":false},"Threads":[{"id":14,"pc":4652512,"file":"/usr/lib/go-1.18/src/runtime/rt0_linux_amd64.s","line":8,"function":{"name":"_rt0_amd64_linux","value":4652512,"type":0,"goType":0,"optimized":true},"goroutineID":0,"ReturnValues":null,"CallReturn":false}],"NextInProgress":false,"WatchOutOfScope":null,"exited":false,"exitStatus":0,"When":""}} error: ""
2022-08-24T13:22:11Z debug layer=rpc <- RPCServer.Recorded(rpc2.RecordedIn{})
2022-08-24T13:22:11Z debug layer=rpc -> *rpc2.RecordedOut{"Recorded":false,"TraceDirectory":""} error: ""
But when I run it with normal command
/server appname --config=configfile.yaml
My expected logs are like:
2022/08/24 07:43:43 maxprocs: Leaving GOMAXPROCS=16: CPU quota undefined
2022-08-24T07:43:44.976Z INFO database/pool.go:35 database configuration {"MaxConns": 8, "RetryCount": 10, "RetryInterval (seconds)": 5}
2022-08-24T07:43:44.976Z INFO v4@v4.15.0/conn.go:355 Dialing PostgreSQL server {"host": "postgres-infras.emulator.svc.cluster.local"}
2022-08-24T07:43:44.980Z INFO nats/jetstream.go:335 nats jetstream connected
2022-08-24T07:43:45.090Z INFO zap/grpclogger.go:92 [core][Channel #1 SubChannel #2] Subchannel Connectivity change to READY {"system": "grpc", "grpc_log": true}
The question is how can I read the actual logs to know the reason why waiter-service is not working when others can?
答案1
得分: 1
你可以添加以下选项:
--continue --headless
相关问题:Go delve --continue
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论