serverReadyAction doesn't work when output is sent to the debug console (ie useTerminal is false)
In version 0.1.0, output is sent by default to the debug console (it used to only go to a new terminal, but now you can choose where it goes via the useTerminal setting).
I'm running a Rails server and the serverReadyAction doesn't execute when output goes to the debug console. However, if I specify "useTerminal": true in launch.json, serverReadyAction works, ie the webpage http://localhost:3000 opens in a browser window.
My launch.json configuration is:
"name": "rdbg",
"type": "rdbg",
"request": "launch",
"script": "${workspaceRoot}/bin/rails",
"cwd": "${workspaceRoot}",
"args": [
"server"
],
"serverReadyAction": {
"pattern": "Listening on http://127.0.0.1:([0-9]+)",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
what is "serverReadyAction"?
serverReadyAction instructs VSCode to scan the log for a pattern and then take an action once it's seen (openExternally tells it to open the uriFormat string in a browser). See https://code.visualstudio.com/docs/editor/debugging#_automatically-open-a-uri-when-debugging-a-server-program.
Thank you for the information. This is first time to see.
Do you know other debuggers (on other languages) support it on the debug console?
Excellent question! I'm not sure about other languages, but serverReadyAction works with output going to the debug console in the "Ruby" extension by Peng Lv (I think it's this one: https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby). It uses the ruby-debug-ide and debase gems.
I just ran it to confirm that a new browser window opens once the Rails server writes "* Listening on http://127.0.0.1:3000" to the debug console. My launch.json contains:
{
"name": "rdebug-ide",
"type": "Ruby",
"request": "launch",
"program": "${workspaceRoot}/bin/rails",
"cwd": "${workspaceRoot}",
"args": [
"server"
],
"serverReadyAction": {
"pattern": "listening on http://127.0.0.1:([0-9]+)",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
},
Thank you so there is a way to support it on the debug console...