perpetualKid/FreeTrainSimulator

Webserver causing orphaned processes when app crashes during initialization

Closed this issue · 2 comments

the webserver keeps sleeping while waiting for an Program.Viewer instance to be assigned

https://github.com/perpetualKid/ORTS-MG/blob/99fadaec4cbf1546de7a07c0b1a5b6fd1da86bb5/Source/ActivityRunner/Viewer3D/WebServices/WebServer.cs#L61-L64

When ActivityRunner crashes during loading and exception is caught in GameStateRunActivity, the webserver keeps waiting causing orphaned application instances and not ending the application properly.

https://github.com/perpetualKid/ORTS-MG/blob/99fadaec4cbf1546de7a07c0b1a5b6fd1da86bb5/Source/ActivityRunner/Viewer3D/Processes/GameStateRunActivity.cs#L205-L261

current workaround - hard exit using Environment.Exit after

https://github.com/perpetualKid/ORTS-MG/blob/99fadaec4cbf1546de7a07c0b1a5b6fd1da86bb5/Source/ActivityRunner/Viewer3D/Processes/GameStateRunActivity.cs#L261

This needs some refactoring. Ideally the web server only needs to start when loading process is finished.

I believe I can reproduce - when I kill the process during loading there's sometimes still a process there and I have to kill it with kill command

preliminary fixed but should be revised when any refactoring in WebServer