-
Notifications
You must be signed in to change notification settings - Fork 12
Description
I'm trying to build a launch configuration that will,
- submit a python script to be ran on a server farm,
- wait for an indication that the script has started a debugpy server, and is listening for connections,
- ascertain the machine that is now listening for a debug client connection, and
- proceed to connect the debugger client to the remote server.
I have coded this solution as follows:
launch.jsonruns apreLaunchTaskcalledlaunchTest, that uses a shell script to,- submit the job to run on the farm.
- waits for a file to exist that contains what machine the job is running on, and also indicates the debug server is now listening.
launch.jsonalso defines the host to connect to as${input:debugpyLauncHost}input:debugpyLauncHostusesextension.commandvariable.file.contentto get the value from the file.
It appears that the launch configuration evaluates the value of ${input:debugpyLauncHost}, before running the preLaunchTask. Because, while launchTest starts the server and the file is created with the machine name, ${input:debugpyLauncHost} returns nothing, and the host connection fails.
I experimented with added delays after the file exists, but regardless of the length it doesn't matter. If on the other hand, I pre-populate the file before running the launch configuration ( and forcing the job to run on that specific machine ), ${input:debugpyLauncHost} successfully returns the machine name from the file and the client connects to the server.
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Py Debugger",
"type": "debugpy",
"preLaunchTask": "launchTest",
"request": "attach",
"connect": {
"host": "${input:debugpyLaunchHost}",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}"
}
],
"postDebugTask": "delete DebugpyLaunchHost.tmp"
}
],
"inputs": [
{
"id": "debugpyLaunchHost",
"type": "command",
"command": "extension.commandvariable.file.content",
"args": {
"fileName": "${workspaceFolder}/.vscode/debugpyLaunchHost.tmp"
}
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "launchTest",
"type": "shell",
"command": "proj_env",
"args": [
"${workspaceFolder}/trunk/script/launch_test.sh"
],
"problemMatcher": []
},
{
"label": "delete DebugpyLaunchHost.tmp",
"type": "shell",
"command": "rm",
"args": [
"${workspaceFolder}/.vscode/debugpyLaunchHost.tmp"
],
"problemMatcher": []
}
]
}
The details of launch_test.sh aren't important, but it's working as expected.
Is there another way to leverage this extension to accomplish my goal?