Files
ArmA-3-web-server/backend/internal/api/router.go
MrFastwind 2d301b95b6 Add server health endpoint and status page
Backend:
- New /api/server/health endpoint returning server, paths, disk,
  mods, steamcmd, and frontend status
- Health endpoint checks directory existence/writability, disk usage,
  server binary, and frontend dist availability

Frontend:
- New Status page (route /status) with sections for Server, SteamCMD,
  Mods, Frontend, Directories (with exists/writable badges), and
  Disk Usage (with size formatting and used-percent coloring)
- Paths are clickable to copy and use start-truncation (ellipsis on
  the left) with native hover tooltip
- Health API client integration with 10s auto-refresh

Misc:
- Update .gitignore and Makefile, minor Layout nav addition
2026-07-09 15:22:43 +02:00

99 lines
3.0 KiB
Go

package api
import (
"arma3-web-server/internal/services"
"github.com/gin-gonic/gin"
)
type Handler struct {
settings *services.SettingsManager
configs *services.ConfigManager
modlists *services.ModlistManager
process *services.ProcessManager
steamcmd *services.SteamCmdManager
scheduler *services.Scheduler
streamer *services.LogStreamer
dataDir string
serverfileDir string
modsDir string
cfgDir string
profilesDir string
frontendDir string
}
func New(
settings *services.SettingsManager,
configs *services.ConfigManager,
modlists *services.ModlistManager,
process *services.ProcessManager,
steamcmd *services.SteamCmdManager,
scheduler *services.Scheduler,
streamer *services.LogStreamer,
dataDir, serverfileDir, modsDir, cfgDir, profilesDir, frontendDir string,
) *Handler {
return &Handler{
settings: settings,
configs: configs,
modlists: modlists,
process: process,
steamcmd: steamcmd,
scheduler: scheduler,
streamer: streamer,
dataDir: dataDir,
serverfileDir: serverfileDir,
modsDir: modsDir,
cfgDir: cfgDir,
profilesDir: profilesDir,
frontendDir: frontendDir,
}
}
func (h *Handler) SetupRoutes(r *gin.Engine) {
api := r.Group("/api")
{
api.GET("/server/settings", h.GetSettings)
api.PUT("/server/settings", h.UpdateSettings)
api.POST("/server/start", h.StartServer)
api.POST("/server/stop", h.StopServer)
api.POST("/server/restart", h.RestartServer)
api.GET("/server/status", h.ServerStatus)
api.GET("/server/steamcmd", h.SteamCMDSettings)
api.POST("/server/steamcmd/update-game", h.SteamCMDUpdateGame)
api.POST("/server/steamcmd/download-mod", h.SteamCMDDownloadMod)
api.GET("/server/steamcmd/status", h.SteamCMDStatus)
api.GET("/server/paths", h.ServerPaths)
api.GET("/server/health", h.Health)
api.GET("/server/logs", h.ListLogs)
api.GET("/server/logs/:file", h.GetLog)
api.GET("/configs", h.ListConfigs)
api.POST("/configs", h.CreateConfig)
api.GET("/configs/:name", h.GetConfig)
api.PUT("/configs/:name", h.UpdateConfig)
api.DELETE("/configs/:name", h.DeleteConfig)
api.POST("/configs/:name/duplicate", h.DuplicateConfig)
api.GET("/modlists", h.ListModlists)
api.POST("/modlists", h.CreateModlist)
api.GET("/modlists/:id", h.GetModlist)
api.PUT("/modlists/:id", h.UpdateModlist)
api.DELETE("/modlists/:id", h.DeleteModlist)
api.POST("/modlists/:id/duplicate", h.DuplicateModlist)
api.POST("/modlists/import", h.ImportModlist)
api.GET("/modlists/:id/check", h.CheckModlistMods)
api.POST("/modlists/:id/download-missing", h.DownloadMissingMods)
api.POST("/modlists/:id/update-all", h.UpdateAllMods)
api.GET("/modlists/:id/export", h.ExportModlist)
api.GET("/mods", h.ListMods)
api.DELETE("/mods", h.DeleteMod)
api.POST("/mods/cleanup", h.CleanupMods)
}
r.GET("/ws/server/logs", h.StreamLogs)
r.GET("/ws/steamcmd/logs", h.StreamSteamCMDLogs)
r.GET("/ws/server/rpt", h.StreamRPTLogs)
}