@@ -80,7 +80,7 @@ let loadGameMaps (datasetDescriptionFilePath:string) =
80
80
maps.Add map
81
81
maps
82
82
83
- let ws outputDirectory ( webSocket : WebSocket ) ( context : HttpContext ) =
83
+ let ws port outputDirectory ( webSocket : WebSocket ) ( context : HttpContext ) =
84
84
let mutable loop = true
85
85
86
86
socket {
@@ -144,6 +144,7 @@ let ws outputDirectory (webSocket : WebSocket) (context: HttpContext) =
144
144
match message with
145
145
| ServerStop -> loop <- false
146
146
| Start gameMap ->
147
+ printfn $" Start map {gameMap.MapName}, port {port}"
147
148
let aiTrainingOptions =
148
149
{
149
150
stepsToSwitchToAI = gameMap.StepsToStart
@@ -164,6 +165,7 @@ let ws outputDirectory (webSocket : WebSocket) (context: HttpContext) =
164
165
API.Reset()
165
166
HashMap.hashMap.Clear()
166
167
do ! sendResponse ( GameOver ( explorationResult.ActualCoverage, explorationResult.TestsCount, explorationResult.ErrorsCount))
168
+ printfn $" Finish map {gameMap.MapName}, port {port}"
167
169
| x -> failwithf $" Unexpected message: %A {x}"
168
170
169
171
| ( Close, _, _) ->
@@ -173,9 +175,9 @@ let ws outputDirectory (webSocket : WebSocket) (context: HttpContext) =
173
175
| _ -> ()
174
176
}
175
177
176
- let app port : WebPart =
178
+ let app port outputDirectory : WebPart =
177
179
choose [
178
- path " /gameServer" >=> handShake ( ws port)
180
+ path " /gameServer" >=> handShake ( ws port outputDirectory )
179
181
]
180
182
181
183
let generateDataForPretraining outputDirectory datasetBasePath ( maps : ResizeArray < GameMap >) stepsToSerialize =
@@ -243,10 +245,15 @@ let main args =
243
245
printfn $" outputDir: {outputDirectory}"
244
246
245
247
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}"
250
257
| Mode.Generator ->
251
258
let maps = loadGameMaps datasetDescription
252
259
generateDataForPretraining outputDirectory datasetBasePath maps stepsToSerialize
0 commit comments