Skip to content

Commit b1d7cce

Browse files
andreaswendlerg3force
authored andcommitted
Add command line option to not serve the UI
1 parent 018e95f commit b1d7cce

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

cmd/ssl-game-controller/main.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@ var publishAddress = flag.String("publishAddress", "", "The address (ip+port) to
2121
var timeAcquisitionMode = flag.String("timeAcquisitionMode", "", "The time acquisitionMode to use (system, ci, vision)")
2222
var skipInterfaces = flag.String("skipInterfaces", "", "Comma separated list of interface names to ignore when receiving multicast packets")
2323
var verbose = flag.Bool("verbose", false, "Verbose output")
24+
var backendOnly = flag.Bool("backendOnly", false, "Do not serve the UI and API")
2425

2526
const configFileName = "config/ssl-game-controller.yaml"
2627

2728
func main() {
2829
flag.Parse()
2930

3031
setupGameController()
32+
33+
if backendOnly != nil && *backendOnly {
34+
blockForever()
35+
return
36+
}
37+
3138
setupUi()
3239

3340
err := http.ListenAndServe(*address, nil)
@@ -36,6 +43,10 @@ func main() {
3643
}
3744
}
3845

46+
func blockForever() {
47+
select {}
48+
}
49+
3950
func setupGameController() {
4051
cfg := config.LoadConfig(configFileName)
4152

@@ -70,8 +81,10 @@ func setupGameController() {
7081
os.Exit(0)
7182
}()
7283

73-
// serve the bidirectional web socket
74-
http.HandleFunc("/api/control", gameController.ApiServer().WsHandler)
84+
if backendOnly == nil || !*backendOnly {
85+
// serve the bidirectional web socket
86+
http.HandleFunc("/api/control", gameController.ApiServer().WsHandler)
87+
}
7588
}
7689

7790
func setupUi() {

0 commit comments

Comments
 (0)