visual-studio-codelaunch

vs code: Launch multiple configurations at once


I am playing around with cluster computing and would like to simulate a cluster with one leader node and multiple follower nodes. I can do that by setting up multiple configurations (one for each node). Now, I would like to run all of these configurations at once (or one after another).

Is it possible to do this?

Someone else already tried to solve this question. The solution they came up with was to have a new launch.json in a new .vscode folder for each configuration. This seems to work, but is impractical since I would like to start e.g. 20 (or 100) nodes.


Solution

  • https://code.visualstudio.com/docs/editor/debugging#_compound-launch-configurations

    Compound launch configurations

    An alternative way to start multiple debug sessions is by using a compound launch configuration. A compound launch configuration lists the names of two or more launch configurations that should be launched in parallel. Optionally a preLaunchTask can be specified that is run before the individual debug sessions are started. The boolean flag stopAll controls whether manually terminating one session will stop all of the compound sessions.

    {
      "version": "0.2.0",
      "configurations": [
        {
          "type": "node",
          "request": "launch",
          "name": "Server",
          "program": "${workspaceFolder}/server.js"
        },
        {
          "type": "node",
          "request": "launch",
          "name": "Client",
          "program": "${workspaceFolder}/client.js"
        }
      ],
      "compounds": [
        {
          "name": "Server/Client",
          "configurations": ["Server", "Client"],
          "preLaunchTask": "${defaultBuildTask}",
          "stopAll": true
        }
      ]
    }
    

    Compound launch configurations are displayed in the launch configuration dropdown menu.