rbanks54 / microcafe

Sample code to show microservices using NET, in the context of a cafe
119 stars 50 forks source link

Topshelf process not really quitting #17

Open vaniovanio opened 7 years ago

vaniovanio commented 7 years ago

Hi,

What could be done in order for the command window to close when the Topshelf service is disposed? I'm not able to find any information on that in the Topshelf documentation. Say, the "Admin.Service.exe" is running, I want to stop it, so I go to the window hosting it and press CTRL+C. This shuts down the service, but the executable is still running (e.g. I can see it in Task Manager). How can I avoid that?

Thanks! And great project, it gave me lots of insight on microservices in .Net.

rbanks54 commented 7 years ago

Running it locally, I can't repro the problem you're having.

In program.cs the line: s.WhenStopped(tc => tc.Stop()); should catch the Ctrl+C and call the stop method in the Admin Service class.

That Stop() method simply calls webApp.Dispose();

So I suspect the Dispose() method is not finishing. Is it possible you have a long running request in your service that is not returning, which in turn is keeping a thread running?