Skip to content

Commit

Permalink
Move library config to the top level
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed Nov 17, 2024
1 parent 795771e commit 45cc9e8
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 28 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/cd/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
37 changes: 19 additions & 18 deletions pkg/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/config/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "flag"
type CoordinatorConfig struct {
Coordinator Coordinator
Emulator Emulator
Library Library
Recording Recording
Version Version
Webrtc Webrtc
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
type WorkerConfig struct {
Encoder Encoder
Emulator Emulator
Library Library
Recording Recording
Storage Storage
Worker Worker
Expand All @@ -31,7 +32,6 @@ type Storage struct {

type Worker struct {
Debug bool
Library Library
Monitoring Monitoring
Network struct {
CoordinatorAddress string
Expand Down
2 changes: 1 addition & 1 deletion pkg/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/worker/caged/libretro/frontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/worker/coordinatorhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/worker/room/room_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 45cc9e8

Please sign in to comment.