From 45cc9e824509c96bc962e3784be6eff282cc1763 Mon Sep 17 00:00:00 2001 From: Sergey Stepanov Date: Wed, 6 Nov 2024 16:28:30 +0300 Subject: [PATCH] Move library config to the top level --- .github/workflows/cd/docker-compose.yml | 10 +++--- pkg/config/config.yaml | 37 +++++++++++----------- pkg/config/coordinator.go | 1 + pkg/config/worker.go | 2 +- pkg/coordinator/coordinator.go | 2 +- pkg/worker/caged/libretro/frontend_test.go | 2 +- pkg/worker/coordinatorhandlers.go | 2 +- pkg/worker/room/room_test.go | 2 +- 8 files changed, 30 insertions(+), 28 deletions(-) diff --git a/.github/workflows/cd/docker-compose.yml b/.github/workflows/cd/docker-compose.yml index c8f4c286..02d94786 100644 --- a/.github/workflows/cd/docker-compose.yml +++ b/.github/workflows/cd/docker-compose.yml @@ -32,7 +32,7 @@ services: <<: *default-params command: ./coordinator environment: - - CLOUD_GAME_COORDINATOR_LIBRARY_BASEPATH=/usr/local/share/cloud-game/assets/games + - CLOUD_GAME_LIBRARY_BASEPATH=/usr/local/share/cloud-game/assets/games volumes: - ${APP_DIR:-/cloud-game}/cache:/usr/local/share/cloud-game/assets/cache - ${APP_DIR:-/cloud-game}/games:/usr/local/share/cloud-game/assets/games @@ -43,7 +43,7 @@ services: environment: - DISPLAY=:99 - MESA_GL_VERSION_OVERRIDE=4.5 - - CLOUD_GAME_WORKER_LIBRARY_BASEPATH=/usr/local/share/cloud-game/assets/games + - CLOUD_GAME_LIBRARY_BASEPATH=/usr/local/share/cloud-game/assets/games - CLOUD_GAME_EMULATOR_LIBRETRO_CORES_PATHS_LIBS=/usr/local/share/cloud-game/assets/cores - CLOUD_GAME_WORKER_SERVER_TLS_DOMAIN=cloudretro.io - CLOUD_GAME_WORKER_SERVER_TLS_ADDRESS=:444 @@ -55,7 +55,7 @@ services: - CLOUD_GAME_WORKER_SERVER_TLS_ADDRESS=:445 - DISPLAY=:99 - MESA_GL_VERSION_OVERRIDE=4.5 - - CLOUD_GAME_WORKER_LIBRARY_BASEPATH=/usr/local/share/cloud-game/assets/games + - CLOUD_GAME_LIBRARY_BASEPATH=/usr/local/share/cloud-game/assets/games - CLOUD_GAME_EMULATOR_LIBRETRO_CORES_PATHS_LIBS=/usr/local/share/cloud-game/assets/cores - CLOUD_GAME_WORKER_SERVER_TLS_DOMAIN=cloudretro.io healthcheck: @@ -65,7 +65,7 @@ services: environment: - DISPLAY=:99 - MESA_GL_VERSION_OVERRIDE=4.5 - - CLOUD_GAME_WORKER_LIBRARY_BASEPATH=/usr/local/share/cloud-game/assets/games + - CLOUD_GAME_LIBRARY_BASEPATH=/usr/local/share/cloud-game/assets/games - CLOUD_GAME_EMULATOR_LIBRETRO_CORES_PATHS_LIBS=/usr/local/share/cloud-game/assets/cores - CLOUD_GAME_WORKER_SERVER_TLS_DOMAIN=cloudretro.io - CLOUD_GAME_WORKER_SERVER_TLS_ADDRESS=:446 @@ -76,7 +76,7 @@ services: environment: - DISPLAY=:99 - MESA_GL_VERSION_OVERRIDE=4.5 - - CLOUD_GAME_WORKER_LIBRARY_BASEPATH=/usr/local/share/cloud-game/assets/games + - CLOUD_GAME_LIBRARY_BASEPATH=/usr/local/share/cloud-game/assets/games - CLOUD_GAME_EMULATOR_LIBRETRO_CORES_PATHS_LIBS=/usr/local/share/cloud-game/assets/cores - CLOUD_GAME_WORKER_SERVER_TLS_DOMAIN=cloudretro.io - CLOUD_GAME_WORKER_SERVER_TLS_ADDRESS=:447 diff --git a/pkg/config/config.yaml b/pkg/config/config.yaml index 460ca86f..d27950f9 100644 --- a/pkg/config/config.yaml +++ b/pkg/config/config.yaml @@ -18,6 +18,25 @@ # for the compatibility purposes version: 3 +# new decentralized library of games +library: + # optional alias file for overriding game names from the basePath path + aliasFile: alias.txt + # root folder for the library (where games are stored) + basePath: assets/games + # a list of ignored words in the ROM filenames + ignored: + - neogeo + - pgm + # an explicit list of supported file extensions + # which overrides Libretro emulator ROMs configs + supported: + # print some additional info + verbose: true + # enable library directory live reload + # (experimental) + watchMode: false + coordinator: # debugging switch # - shows debug logs @@ -27,24 +46,6 @@ coordinator: # - empty value (default, any free) # - ping (with the lowest ping) selector: - # games library - library: - # optional alias file for overriding game names from the basePath path - aliasFile: alias.txt - # root folder for the library (where games are stored) - basePath: assets/games - # an explicit list of supported file extensions - # which overrides Libretro emulator ROMs configs - supported: - # a list of ignored words in the ROM filenames - ignored: - - neogeo - - pgm - # print some additional info - verbose: true - # enable library directory live reload - # (experimental) - watchMode: false monitoring: port: 6601 # enable Go profiler HTTP server diff --git a/pkg/config/coordinator.go b/pkg/config/coordinator.go index dd904880..daa9b393 100644 --- a/pkg/config/coordinator.go +++ b/pkg/config/coordinator.go @@ -5,6 +5,7 @@ import "flag" type CoordinatorConfig struct { Coordinator Coordinator Emulator Emulator + Library Library Recording Recording Version Version Webrtc Webrtc diff --git a/pkg/config/worker.go b/pkg/config/worker.go index 21da91e6..9e865672 100644 --- a/pkg/config/worker.go +++ b/pkg/config/worker.go @@ -14,6 +14,7 @@ import ( type WorkerConfig struct { Encoder Encoder Emulator Emulator + Library Library Recording Recording Storage Storage Worker Worker @@ -31,7 +32,6 @@ type Storage struct { type Worker struct { Debug bool - Library Library Monitoring Monitoring Network struct { CoordinatorAddress string diff --git a/pkg/coordinator/coordinator.go b/pkg/coordinator/coordinator.go index 9a257457..61dcf43c 100644 --- a/pkg/coordinator/coordinator.go +++ b/pkg/coordinator/coordinator.go @@ -24,7 +24,7 @@ type Coordinator struct { func New(conf config.CoordinatorConfig, log *logger.Logger) (*Coordinator, error) { coordinator := &Coordinator{} - lib := games.NewLib(conf.Coordinator.Library, conf.Emulator, log) + lib := games.NewLib(conf.Library, conf.Emulator, log) lib.Scan() coordinator.hub = NewHub(conf, lib, log) h, err := NewHTTPServer(conf, log, func(mux *httpx.Mux) *httpx.Mux { diff --git a/pkg/worker/caged/libretro/frontend_test.go b/pkg/worker/caged/libretro/frontend_test.go index 41bd835c..e4c4105c 100644 --- a/pkg/worker/caged/libretro/frontend_test.go +++ b/pkg/worker/caged/libretro/frontend_test.go @@ -92,7 +92,7 @@ func EmulatorMock(room string, system string) *TestFrontend { SaveOnClose: false, }, corePath: expand(conf.Emulator.GetLibretroCoreConfig(system).Lib), - gamePath: expand(conf.Worker.Library.BasePath), + gamePath: expand(conf.Library.BasePath), system: system, } emu.linkNano(nano) diff --git a/pkg/worker/coordinatorhandlers.go b/pkg/worker/coordinatorhandlers.go index da013ef4..120318da 100644 --- a/pkg/worker/coordinatorhandlers.go +++ b/pkg/worker/coordinatorhandlers.go @@ -141,7 +141,7 @@ func (c *coordinator) HandleGameStart(rq api.StartGameRequest[com.Uid], w *Worke }) w.log.Info().Msgf("Starting the game: %v", rq.Game.Name) - if err := app.Load(game, w.conf.Worker.Library.BasePath); err != nil { + if err := app.Load(game, w.conf.Library.BasePath); err != nil { c.log.Error().Err(err).Msgf("couldn't load the game %v", game) r.Close() w.router.SetRoom(nil) diff --git a/pkg/worker/room/room_test.go b/pkg/worker/room/room_test.go index 4aa3a748..a33e4d82 100644 --- a/pkg/worker/room/room_test.go +++ b/pkg/worker/room/room_test.go @@ -223,7 +223,7 @@ func room(cfg conf) testRoom { emu := WithEmulator(manager.Get(caged.Libretro)) emu.ReloadFrontend() emu.SetSessionId(id) - if err := emu.Load(cfg.game, conf.Worker.Library.BasePath); err != nil { + if err := emu.Load(cfg.game, conf.Library.BasePath); err != nil { l.Fatal().Err(err).Msgf("couldn't load the game %v", cfg.game) }