How to make windows terminal not gain focus when starting microservices

123 views Asked by At

I am running an application in Visual Studio with around 50+ microservices. All the microservices starts in on windows terminal as different tabs. The problem is that when i start my app this windows terminal will gain focus everytime something is happening in that windows terminal so i can basically not do anything for about 1 minute. Is there a way to tell windows terminal not to gain focus? Or maybe there is another way run the microservices?

Thanks

I tried different settings in windows terminal but nothing seems to work there.

1

There are 1 answers

0
zadjii On

What's happening here is your microservices are all console applications, and Windows determined that they want a visible console window, so Windows is going to create a terminal for them. It's going to use the "default terminal application" to host these console apps, which I'm suspecting you have set to Windows Terminal. WT is then creating tabs for the incoming console apps, then the apps run and exit, closing the tab in the Terminal.

You've got a couple possible solutions:

  1. Most correctly: Spawn these microservices as hidden console windows. Or minimized. The Default Terminal handoff only happens if an app wants a visible console window. A hidden console window won't handoff to your registered terminal app. (This will have the added benefit of preventing console windows from popping up and quickly exiting as you run your application). How exactly to do this will depend on the language you're using to spawn these microservice processes.
  2. Another workaround: Change the Default Terminal Application in the Windows Settings to "Console Host". This is the vintage console window.

I'd really recommend the first though - asking users to change their default terminal is probably not the most polite thing to do. Plus, if you can avoid allocating a console host window just to run a process that doesn't really need one, you probably should.