@@ -80,7 +80,7 @@ let loadGameMaps (datasetDescriptionFilePath:string) =
8080 maps.Add map
8181 maps
8282
83- let ws outputDirectory ( webSocket : WebSocket ) ( context : HttpContext ) =
83+ let ws port outputDirectory ( webSocket : WebSocket ) ( context : HttpContext ) =
8484 let mutable loop = true
8585
8686 socket {
@@ -144,6 +144,7 @@ let ws outputDirectory (webSocket : WebSocket) (context: HttpContext) =
144144 match message with
145145 | ServerStop -> loop <- false
146146 | Start gameMap ->
147+ printfn $" Start map {gameMap.MapName}, port {port}"
147148 let aiTrainingOptions =
148149 {
149150 stepsToSwitchToAI = gameMap.StepsToStart
@@ -164,6 +165,7 @@ let ws outputDirectory (webSocket : WebSocket) (context: HttpContext) =
164165 API.Reset()
165166 HashMap.hashMap.Clear()
166167 do ! sendResponse ( GameOver ( explorationResult.ActualCoverage, explorationResult.TestsCount, explorationResult.ErrorsCount))
168+ printfn $" Finish map {gameMap.MapName}, port {port}"
167169 | x -> failwithf $" Unexpected message: %A {x}"
168170
169171 | ( Close, _, _) ->
@@ -173,9 +175,9 @@ let ws outputDirectory (webSocket : WebSocket) (context: HttpContext) =
173175 | _ -> ()
174176 }
175177
176- let app port : WebPart =
178+ let app port outputDirectory : WebPart =
177179 choose [
178- path " /gameServer" >=> handShake ( ws port)
180+ path " /gameServer" >=> handShake ( ws port outputDirectory )
179181 ]
180182
181183let generateDataForPretraining outputDirectory datasetBasePath ( maps : ResizeArray < GameMap >) stepsToSerialize =
@@ -243,10 +245,15 @@ let main args =
243245 printfn $" outputDir: {outputDirectory}"
244246
245247 match mode with
246- | Mode.Server ->
247- startWebServer { defaultConfig with
248- logger = Targets.create Verbose [||]
249- bindings = [ HttpBinding.createSimple HTTP " 127.0.0.1" port]} ( app outputDirectory)
248+ | Mode.Server ->
249+ try
250+ startWebServer { defaultConfig with
251+ logger = Targets.create Verbose [||]
252+ bindings = [ HttpBinding.createSimple HTTP " 127.0.0.1" port]} ( app port outputDirectory)
253+ with
254+ | e ->
255+ printfn $" Failed on port {port}"
256+ printfn $" {e.Message}"
250257 | Mode.Generator ->
251258 let maps = loadGameMaps datasetDescription
252259 generateDataForPretraining outputDirectory datasetBasePath maps stepsToSerialize
0 commit comments