-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Hi! I'll try to explain what my problem is.
I just switched to Solid Queue for background job, and I couldn't get rdbg to run on a TCP port because of the way Solid Queue handles child processes, so I ended up using a socket instead.
However Solid Queue is running in a remote container in a Kubernetes cluster, and I am trying to debug remotely since I use Okteto to work with the cluster.
Since it's a remote container, I am using socat in the container to expose the unix socket via a TCP port which I can then port-forward to my local machine. This works great and VsCode can connect to the debugger as expected.
However with this configuration VsCode has trouble setting the breakpoints, because a newline character is appended to the filename so it cannot find the file locally, event though the path - minus the newline character at the end - does exist and is valid.
My launch configuration:
{
"type": "rdbg",
"name": "Attach with rdbg (worker)",
"request": "attach",
"debugPort": "0.0.0.0:32002",
"localfsMap": "/home/app/backend:${workspaceFolder}",
"showProtocolLog": true
},Where /home/app/backend is the root of the Rails app in the container, and 32002 is the port at which socat exposes the unix socket in the remote container, and then that port is forwarded to my local machine at 0.0.0.0.
Start script in the container that exposes the unix socket via tcp:
SOCKET_FILE=/var/run/rdbg.socket
RUBY_DEBUG_FORK_MODE=child bundle exec rdbg --sock_path $SOCKET_FILE --open --nonstop -c -- bundle exec rake solid_queue:work &
while [ ! -S $SOCKET_FILE ]; do
echo "Waiting for debugger socket to be available..."
sleep 1
done
sleep 3
socat TCP-LISTEN:32002,fork,bind=0.0.0.0 UNIX-CONNECT:$SOCKET_FILE &
wait -nIn the debugger output in VsCode I see this when I set a breakpoint:
[DA->VSCode] {"type":"event","event":"output","body":{"category":"console","output":"No such file or directory @ rb_check_realpath_internal - /Users/vito/Cloud/Vito/Code/brella/brella-backend-1/app/jobs/approaching_meeting_notification_job.rb\n"},"seq":12}
Notice the \n at the end of the path. I believe this is why it cannot find the file and therefore the breakpoint doesn't work. But like I said the path, without the newline character at the end, does exist and points to the expected file.
Are there any workarounds? Is this an actual bug or am I missing something in my configuration?
Perhaps also worth mentioning that with the same lunch configuration for other processes that can use rdbg with a tcp port directly, all works great. So the problem occurs only with the unix socket config.
Thanks in advance for any help!