Private
Public Access
1
0

Add NATS deployment and service configuration, integrate environment variables, and update server to support NATS and Redis connections.
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m24s

This commit is contained in:
Sebastian Unterschütz
2026-01-04 15:37:09 +01:00
parent ecd994ae73
commit 43680ece16
4 changed files with 73 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"io/ioutil"
"log"
"os"
"path/filepath"
"sync"
@@ -29,12 +30,14 @@ func main() {
loadServerAssets(globalWorld)
// 1b. Redis-Leaderboard initialisieren
if err := server.InitLeaderboard("localhost:6379"); err != nil {
redisAddr := getEnv("REDIS_ADDR", "localhost:6379")
if err := server.InitLeaderboard(redisAddr); err != nil {
log.Fatal("❌ Konnte nicht zu Redis verbinden: ", err)
}
log.Printf("✅ Verbunden mit Redis: %s", redisAddr)
// 2. NATS VERBINDUNG
natsURL := "nats://localhost:4222"
natsURL := getEnv("NATS_URL", "nats://localhost:4222")
nc, err := nats.Connect(natsURL)
if err != nil {
log.Fatal("❌ Konnte nicht zu NATS verbinden: ", err)
@@ -179,6 +182,13 @@ func main() {
}
}
func getEnv(key, defaultValue string) string {
if value := os.Getenv(key); value != "" {
return value
}
return defaultValue
}
func loadServerAssets(w *game.World) {
assetDir := "./cmd/client/web/assets"
chunkDir := filepath.Join(assetDir, "chunks")