This question is about remote debugging of golang code using the delve debugger. Specifically, how to disconnect the client debugger without killing the remote process.
I run a process inside a docker container that needs to be debugged. The process is started in the docker's entrypoint via
dlv debug /go/src/path/to/package --headless --listen=:2345 --log
The docker container is started via
docker run --rm -it -p 2345:2345 my_image:tag
From my workstation I connect to the delve headless server via
$dlv connect :2345
Type 'help' for list of commands.
(dlv)
At that point I do some debugging. When I'm done I'd like the ability to disconnect from the headless server without killing the process being debugged.
(dlv) exit
Unfortunately the above command disconnects the delve client from the headless server and also kills the remote process I was debugging, and since that was the docker container's entrypoint, the container stops. I'd like to avoid disconnecting from killing the remote process, how?
I've looked at the arguments to (dlv) exit
, and cannot see one that would help.
(dlv) help exit
Exit the debugger.
exit [-c]
When connected to a headless instance started with the --accept-multiclient, pass -c to resume the execution of the target process before disconnecting.
(dlv) exit -c
Command failed: not connected to an --accept-multiclient server