feat: add Wine Z: path prefix for Windows platform on Linux host
CI / build (push) Successful in 1m44s
CI / build (push) Successful in 1m44s
- Add winePath helper that prepends Z: when platform is windows on Linux - Thread platform through buildModPath, buildAutoArgs, and Start() - Apply Z: prefix to -config=, -mod=, -profiles=, and %command% binary paths - Add tests for winePath, buildAutoArgs, and buildModPath with platform param - Fix formatting across services package with gofmt - Include all prior bug fixes from this branch
This commit is contained in:
@@ -16,6 +16,8 @@ jobs:
|
|||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: "22"
|
node-version: "22"
|
||||||
|
- run: cd frontend && npm ci && npm run build
|
||||||
|
- run: mkdir -p backend/embed/dist && cp -r frontend/dist/. backend/embed/dist/
|
||||||
- run: cd backend && go build ./...
|
- run: cd backend && go build ./...
|
||||||
- run: cd backend && go test ./...
|
- run: cd backend && go test ./...
|
||||||
- run: cd frontend && npm ci && npm run build && npm test
|
- run: cd frontend && npm test
|
||||||
|
|||||||
+3
-4
@@ -69,8 +69,7 @@ arma3-web-server/
|
|||||||
│ │ └── components/
|
│ │ └── components/
|
||||||
│ │ ├── ConfigEditor.tsx # Monaco editor wrapper
|
│ │ ├── ConfigEditor.tsx # Monaco editor wrapper
|
||||||
│ │ ├── LiveTerminal.tsx # xterm.js + auto-reconnect WebSocket
|
│ │ ├── LiveTerminal.tsx # xterm.js + auto-reconnect WebSocket
|
||||||
│ │ ├── Layout.tsx # Sidebar navigation shell
|
│ │ └── Layout.tsx # Sidebar navigation shell
|
||||||
│ │ └── ui/ # Empty
|
|
||||||
│ ├── package.json
|
│ ├── package.json
|
||||||
│ ├── vite.config.ts # Proxy /api + /ws to :8080
|
│ ├── vite.config.ts # Proxy /api + /ws to :8080
|
||||||
│ └── tsconfig*.json
|
│ └── tsconfig*.json
|
||||||
@@ -116,8 +115,8 @@ arma3-web-server/
|
|||||||
| `oxlint` | linter | ^1.71.0 | Linting |
|
| `oxlint` | linter | ^1.71.0 | Linting |
|
||||||
| `vitest` | test runner | ^4.1.10 | Frontend unit/integration tests |
|
| `vitest` | test runner | ^4.1.10 | Frontend unit/integration tests |
|
||||||
| `@testing-library/react` | test utility | ^16.3.0 | React component testing |
|
| `@testing-library/react` | test utility | ^16.3.0 | React component testing |
|
||||||
| `@testing-library/jest-dom` | test matcher | ^6.6.3 | DOM assertion matchers |
|
| `@testing-library/jest-dom` | test matcher | ^7.0.0 | DOM assertion matchers |
|
||||||
| `jsdom` | test env | ^26.1.0 | Browser environment for tests |
|
| `jsdom` | test env | ^29.1.1 | Browser environment for tests |
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ RUN apt-get update && \
|
|||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY --from=backend /server /usr/local/bin/arma3-web-server
|
COPY --from=backend /server /usr/local/bin/arma3-web-server
|
||||||
COPY --from=frontend /src/dist /usr/share/arma3-web-server/frontend
|
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
VOLUME ["/data", "/servers"]
|
VOLUME ["/data", "/servers"]
|
||||||
@@ -38,7 +37,6 @@ ENV MODS_DIR=/servers/mods
|
|||||||
ENV CFG_DIR=/servers/cfg
|
ENV CFG_DIR=/servers/cfg
|
||||||
ENV PROFILES_DIR=/servers/profiles
|
ENV PROFILES_DIR=/servers/profiles
|
||||||
ENV LISTEN=:8080
|
ENV LISTEN=:8080
|
||||||
ENV FRONTEND_DIR=/usr/share/arma3-web-server/frontend
|
|
||||||
ENV GIN_MODE=release
|
ENV GIN_MODE=release
|
||||||
|
|
||||||
ENTRYPOINT ["arma3-web-server"]
|
ENTRYPOINT ["arma3-web-server"]
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ RUN apt-get update && \
|
|||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY arma3-web-server /usr/local/bin/arma3-web-server
|
COPY arma3-web-server /usr/local/bin/arma3-web-server
|
||||||
COPY frontend/dist /usr/share/arma3-web-server/frontend
|
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
VOLUME ["/data", "/servers"]
|
VOLUME ["/data", "/servers"]
|
||||||
@@ -25,7 +24,6 @@ ENV MODS_DIR=/servers/mods
|
|||||||
ENV CFG_DIR=/servers/cfg
|
ENV CFG_DIR=/servers/cfg
|
||||||
ENV PROFILES_DIR=/servers/profiles
|
ENV PROFILES_DIR=/servers/profiles
|
||||||
ENV LISTEN=:8080
|
ENV LISTEN=:8080
|
||||||
ENV FRONTEND_DIR=/usr/share/arma3-web-server/frontend
|
|
||||||
ENV GIN_MODE=release
|
ENV GIN_MODE=release
|
||||||
|
|
||||||
ENTRYPOINT ["arma3-web-server"]
|
ENTRYPOINT ["arma3-web-server"]
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
.PHONY: backend frontend build run clean dev test test-backend test-frontend
|
.PHONY: backend frontend build run clean dev test test-backend test-frontend
|
||||||
|
|
||||||
# Default paths for dev — override via env (absolute to avoid CWD mismatches)
|
# Default paths for dev — override via env (absolute to avoid CWD mismatches)
|
||||||
SERVERFILE_DIR ?= $(abspath ../dev-deploy/serverfiles)
|
SERVERFILE_DIR ?= $(abspath dev-deploy/serverfiles)
|
||||||
MODS_DIR ?= $(abspath ../dev-deploy/serverfiles/mods)
|
MODS_DIR ?= $(abspath dev-deploy/serverfiles/mods)
|
||||||
CFG_DIR ?= $(abspath ../dev-deploy/serverfiles/cfg)
|
CFG_DIR ?= $(abspath dev-deploy/serverfiles/cfg)
|
||||||
PROFILES_DIR ?= $(abspath ../dev-deploy/serverfiles/profiles)
|
PROFILES_DIR ?= $(abspath dev-deploy/serverfiles/profiles)
|
||||||
DATA_DIR ?= $(abspath ../dev-deploy/data)
|
DATA_DIR ?= $(abspath dev-deploy/data)
|
||||||
|
|
||||||
# Server/steamcmd overrides — set to use stubs in dev
|
# Server/steamcmd overrides — set to use stubs in dev
|
||||||
SERVER_BINARY ?= arma3server_x64
|
SERVER_BINARY ?= arma3server_x64
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ arma3-web-server/
|
|||||||
│ │ └── components/
|
│ │ └── components/
|
||||||
│ │ ├── ConfigEditor.tsx # Monaco editor wrapper
|
│ │ ├── ConfigEditor.tsx # Monaco editor wrapper
|
||||||
│ │ ├── LiveTerminal.tsx # xterm.js + auto-reconnect WebSocket
|
│ │ ├── LiveTerminal.tsx # xterm.js + auto-reconnect WebSocket
|
||||||
│ │ ├── Layout.tsx # Sidebar nav shell
|
│ │ └── Layout.tsx # Sidebar nav shell
|
||||||
│ │ └── ui/ # (empty — reserved for future shared UI primitives)
|
|
||||||
│ ├── package.json
|
│ ├── package.json
|
||||||
│ └── vite.config.ts # Proxy /api + /ws to :8080
|
│ └── vite.config.ts # Proxy /api + /ws to :8080
|
||||||
├── data/ # Runtime data (mounted volume in Docker)
|
├── data/ # Runtime data (mounted volume in Docker)
|
||||||
|
|||||||
@@ -57,9 +57,11 @@ func main() {
|
|||||||
|
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
|
|
||||||
|
frontendServed := false
|
||||||
subFS, subErr := fs.Sub(embed.Frontend, "dist")
|
subFS, subErr := fs.Sub(embed.Frontend, "dist")
|
||||||
if subErr == nil {
|
if subErr == nil {
|
||||||
if _, err := subFS.Open("index.html"); err == nil {
|
if _, err := subFS.Open("index.html"); err == nil {
|
||||||
|
frontendServed = true
|
||||||
r.NoRoute(func(c *gin.Context) {
|
r.NoRoute(func(c *gin.Context) {
|
||||||
path := strings.TrimPrefix(c.Request.URL.Path, "/")
|
path := strings.TrimPrefix(c.Request.URL.Path, "/")
|
||||||
if path == "" {
|
if path == "" {
|
||||||
@@ -81,7 +83,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handler := api.New(settings, configMgr, modlistMgr, process, steamcmd, scheduler, streamer, dataDir, serverfileDir, modsDir, cfgDir, profilesDir)
|
handler := api.New(settings, configMgr, modlistMgr, process, steamcmd, scheduler, streamer, dataDir, serverfileDir, modsDir, cfgDir, profilesDir, frontendServed)
|
||||||
handler.SetupRoutes(r)
|
handler.SetupRoutes(r)
|
||||||
|
|
||||||
// Startup auto-tasks
|
// Startup auto-tasks
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ func (h *Handler) Health(c *gin.Context) {
|
|||||||
Running: h.steamcmd.IsRunning(),
|
Running: h.steamcmd.IsRunning(),
|
||||||
},
|
},
|
||||||
Frontend: FrontendHealth{
|
Frontend: FrontendHealth{
|
||||||
Served: true,
|
Served: h.frontendServed,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,8 +140,6 @@ func findServerBinary(serverfileDir string) (string, bool) {
|
|||||||
candidates := []string{"arma3server_x64"}
|
candidates := []string{"arma3server_x64"}
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
candidates = append(candidates, "arma3server_x64.exe")
|
candidates = append(candidates, "arma3server_x64.exe")
|
||||||
} else {
|
|
||||||
candidates = append(candidates, "arma3server_x64.exe")
|
|
||||||
}
|
}
|
||||||
for _, name := range candidates {
|
for _, name := range candidates {
|
||||||
p := filepath.Join(serverfileDir, name)
|
p := filepath.Join(serverfileDir, name)
|
||||||
|
|||||||
@@ -117,7 +117,9 @@ func (h *Handler) StreamRPTLogs(c *gin.Context) {
|
|||||||
if currentPath == "" {
|
if currentPath == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
conn.WriteMessage(websocket.TextMessage, []byte("--- tailing: "+filepath.Base(currentPath)+" ---"))
|
if err := conn.WriteMessage(websocket.TextMessage, []byte("--- tailing: "+filepath.Base(currentPath)+" ---")); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if currentPath == "" {
|
if currentPath == "" {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ type Handler struct {
|
|||||||
modsDir string
|
modsDir string
|
||||||
cfgDir string
|
cfgDir string
|
||||||
profilesDir string
|
profilesDir string
|
||||||
|
frontendServed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(
|
func New(
|
||||||
@@ -30,6 +31,7 @@ func New(
|
|||||||
scheduler *services.Scheduler,
|
scheduler *services.Scheduler,
|
||||||
streamer *services.LogStreamer,
|
streamer *services.LogStreamer,
|
||||||
dataDir, serverfileDir, modsDir, cfgDir, profilesDir string,
|
dataDir, serverfileDir, modsDir, cfgDir, profilesDir string,
|
||||||
|
frontendServed bool,
|
||||||
) *Handler {
|
) *Handler {
|
||||||
return &Handler{
|
return &Handler{
|
||||||
settings: settings,
|
settings: settings,
|
||||||
@@ -44,6 +46,7 @@ func New(
|
|||||||
modsDir: modsDir,
|
modsDir: modsDir,
|
||||||
cfgDir: cfgDir,
|
cfgDir: cfgDir,
|
||||||
profilesDir: profilesDir,
|
profilesDir: profilesDir,
|
||||||
|
frontendServed: frontendServed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ func (s *Scheduler) runScheduledUpdate() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if sett.SteamUser != "" && sett.SteamUser != "anonymous" {
|
if sett.SteamUser != "" {
|
||||||
log.Print("scheduler: running gameserver update")
|
log.Print("scheduler: running gameserver update")
|
||||||
if err := s.steamcmd.UpdateGame(sett.SteamBranch, sett.SteamUser); err != nil {
|
if err := s.steamcmd.UpdateGame(sett.SteamBranch, sett.SteamUser); err != nil {
|
||||||
log.Printf("scheduler: game update failed: %v", err)
|
log.Printf("scheduler: game update failed: %v", err)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@@ -14,6 +15,13 @@ import (
|
|||||||
"arma3-web-server/internal/models"
|
"arma3-web-server/internal/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func winePath(path, platform string) string {
|
||||||
|
if platform == "windows" && runtime.GOOS != "windows" {
|
||||||
|
return "Z:" + path
|
||||||
|
}
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
type procState int32
|
type procState int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -101,7 +109,7 @@ func (pm *ProcessManager) Start() error {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
if strings.Contains(s.ServerParameters, "%command%") {
|
if strings.Contains(s.ServerParameters, "%command%") {
|
||||||
full := strings.ReplaceAll(s.ServerParameters, "%command%", binPath)
|
full := strings.ReplaceAll(s.ServerParameters, "%command%", winePath(binPath, s.Platform))
|
||||||
parts := splitArgs(full)
|
parts := splitArgs(full)
|
||||||
if len(parts) == 0 {
|
if len(parts) == 0 {
|
||||||
cancel()
|
cancel()
|
||||||
@@ -205,18 +213,18 @@ func (pm *ProcessManager) buildAutoArgs(s *models.ServerSettings) []string {
|
|||||||
|
|
||||||
if s.ActiveConfig != "" {
|
if s.ActiveConfig != "" {
|
||||||
cfgPath := filepath.Join(pm.cfgDir, s.ActiveConfig+".cfg")
|
cfgPath := filepath.Join(pm.cfgDir, s.ActiveConfig+".cfg")
|
||||||
args = append(args, "-config="+cfgPath)
|
args = append(args, "-config="+winePath(cfgPath, s.Platform))
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.ActiveModlist != "" {
|
if s.ActiveModlist != "" {
|
||||||
modPath := pm.buildModPath(s.ActiveModlist)
|
modPath := pm.buildModPath(s.ActiveModlist, s.Platform)
|
||||||
if modPath != "" {
|
if modPath != "" {
|
||||||
args = append(args, modPath)
|
args = append(args, modPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if pm.profilesDir != "" && !hasArgPrefix(args, "-profiles=") {
|
if pm.profilesDir != "" && !hasArgPrefix(args, "-profiles=") {
|
||||||
args = append(args, "-profiles="+pm.profilesDir)
|
args = append(args, "-profiles="+winePath(pm.profilesDir, s.Platform))
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.IPPort != "" && !hasArgPrefix(args, "-port=") {
|
if s.IPPort != "" && !hasArgPrefix(args, "-port=") {
|
||||||
@@ -245,7 +253,7 @@ func hasArgPrefix(args []string, prefix string) bool {
|
|||||||
|
|
||||||
const workshopAppID = "107410"
|
const workshopAppID = "107410"
|
||||||
|
|
||||||
func (pm *ProcessManager) buildModPath(modlistID string) string {
|
func (pm *ProcessManager) buildModPath(modlistID string, platform string) string {
|
||||||
ml, err := pm.modlists.Get(modlistID)
|
ml, err := pm.modlists.Get(modlistID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
@@ -256,7 +264,7 @@ func (pm *ProcessManager) buildModPath(modlistID string) string {
|
|||||||
if !mod.Enabled {
|
if !mod.Enabled {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
parts = append(parts, pm.resolveModPath(mod))
|
parts = append(parts, winePath(pm.resolveModPath(mod), platform))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(parts) == 0 {
|
if len(parts) == 0 {
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ func TestBuildModPath_MultipleMods(t *testing.T) {
|
|||||||
{Name: "DisabledMod", Enabled: false},
|
{Name: "DisabledMod", Enabled: false},
|
||||||
})
|
})
|
||||||
|
|
||||||
got := pm.buildModPath(ml.ID)
|
got := pm.buildModPath(ml.ID, "")
|
||||||
if !strings.HasPrefix(got, "-mod=") {
|
if !strings.HasPrefix(got, "-mod=") {
|
||||||
t.Errorf("expected -mod= prefix, got %q", got)
|
t.Errorf("expected -mod= prefix, got %q", got)
|
||||||
}
|
}
|
||||||
@@ -321,7 +321,7 @@ func TestBuildModPath_EmptyModlist(t *testing.T) {
|
|||||||
|
|
||||||
pm := NewProcessManager(dir, modsDir, filepath.Join(dir, "cfg"), filepath.Join(dir, "profiles"), sm, mm, cm, streamer)
|
pm := NewProcessManager(dir, modsDir, filepath.Join(dir, "cfg"), filepath.Join(dir, "profiles"), sm, mm, cm, streamer)
|
||||||
|
|
||||||
got := pm.buildModPath("nonexistent-id")
|
got := pm.buildModPath("nonexistent-id", "")
|
||||||
if got != "" {
|
if got != "" {
|
||||||
t.Errorf("buildModPath(nonexistent) = %q, want empty", got)
|
t.Errorf("buildModPath(nonexistent) = %q, want empty", got)
|
||||||
}
|
}
|
||||||
@@ -396,6 +396,142 @@ func TestWriteUserconfigFiles_EmptyContent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWinePath(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
path string
|
||||||
|
platform string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{"linux platform returns as-is", "/server/cfg/test.cfg", "linux", "/server/cfg/test.cfg"},
|
||||||
|
{"empty platform returns as-is", "/server/cfg/test.cfg", "", "/server/cfg/test.cfg"},
|
||||||
|
{"windows platform on linux adds prefix", "/server/cfg/test.cfg", "windows", "Z:/server/cfg/test.cfg"},
|
||||||
|
{"empty path linux", "", "linux", ""},
|
||||||
|
{"empty path windows", "", "windows", "Z:"},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := winePath(tt.path, tt.platform)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("winePath(%q, %q) = %q, want %q", tt.path, tt.platform, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildAutoArgs_WindowsPlatform(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
cfgDir := filepath.Join(dir, "cfg")
|
||||||
|
profilesDir := filepath.Join(dir, "profiles")
|
||||||
|
modsDir := filepath.Join(dir, "mods")
|
||||||
|
|
||||||
|
sm := NewSettingsManager(dir)
|
||||||
|
mm := NewModlistManager(filepath.Join(dir, "modlists"))
|
||||||
|
cm := NewConfigManager(cfgDir)
|
||||||
|
streamer := NewLogStreamer()
|
||||||
|
|
||||||
|
pm := NewProcessManager(dir, modsDir, cfgDir, profilesDir, sm, mm, cm, streamer)
|
||||||
|
|
||||||
|
s := &models.ServerSettings{
|
||||||
|
Platform: "windows",
|
||||||
|
ActiveConfig: "server_config",
|
||||||
|
IPPort: "0.0.0.0:2302",
|
||||||
|
}
|
||||||
|
|
||||||
|
args := pm.buildAutoArgs(s)
|
||||||
|
|
||||||
|
foundConfig := false
|
||||||
|
foundProfiles := false
|
||||||
|
for _, a := range args {
|
||||||
|
if strings.HasPrefix(a, "-config=Z:") && strings.HasSuffix(a, "server_config.cfg") {
|
||||||
|
foundConfig = true
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(a, "-profiles=Z:") {
|
||||||
|
foundProfiles = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !foundConfig {
|
||||||
|
t.Errorf("expected -config=Z:...server_config.cfg in args, got %v", args)
|
||||||
|
}
|
||||||
|
if !foundProfiles {
|
||||||
|
t.Errorf("expected -profiles=Z:... in args, got %v", args)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildAutoArgs_LinuxPlatform(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
cfgDir := filepath.Join(dir, "cfg")
|
||||||
|
profilesDir := filepath.Join(dir, "profiles")
|
||||||
|
modsDir := filepath.Join(dir, "mods")
|
||||||
|
|
||||||
|
sm := NewSettingsManager(dir)
|
||||||
|
mm := NewModlistManager(filepath.Join(dir, "modlists"))
|
||||||
|
cm := NewConfigManager(cfgDir)
|
||||||
|
streamer := NewLogStreamer()
|
||||||
|
|
||||||
|
pm := NewProcessManager(dir, modsDir, cfgDir, profilesDir, sm, mm, cm, streamer)
|
||||||
|
|
||||||
|
s := &models.ServerSettings{
|
||||||
|
Platform: "linux",
|
||||||
|
ActiveConfig: "server_config",
|
||||||
|
IPPort: "0.0.0.0:2302",
|
||||||
|
}
|
||||||
|
|
||||||
|
args := pm.buildAutoArgs(s)
|
||||||
|
|
||||||
|
for _, a := range args {
|
||||||
|
if strings.HasPrefix(a, "-config=Z:") {
|
||||||
|
t.Errorf("unexpected Z: prefix in args: %v", a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildModPath_WindowsPlatform(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
modsDir := filepath.Join(dir, "mods")
|
||||||
|
os.MkdirAll(filepath.Join(modsDir, "@CBA_A3"), 0755)
|
||||||
|
|
||||||
|
sm := NewSettingsManager(dir)
|
||||||
|
mm := NewModlistManager(filepath.Join(dir, "modlists"))
|
||||||
|
cm := NewConfigManager(filepath.Join(dir, "cfg"))
|
||||||
|
streamer := NewLogStreamer()
|
||||||
|
|
||||||
|
pm := NewProcessManager(dir, modsDir, filepath.Join(dir, "cfg"), filepath.Join(dir, "profiles"), sm, mm, cm, streamer)
|
||||||
|
|
||||||
|
ml, _ := mm.Create("Test List")
|
||||||
|
mm.Update(ml.ID, "Test List", []models.ModEntry{
|
||||||
|
{Name: "CBA_A3", Enabled: true},
|
||||||
|
})
|
||||||
|
|
||||||
|
got := pm.buildModPath(ml.ID, "windows")
|
||||||
|
if !strings.HasPrefix(got, "-mod=Z:") {
|
||||||
|
t.Errorf("expected -mod=Z: prefix, got %q", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildModPath_LinuxPlatform(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
modsDir := filepath.Join(dir, "mods")
|
||||||
|
os.MkdirAll(filepath.Join(modsDir, "@CBA_A3"), 0755)
|
||||||
|
|
||||||
|
sm := NewSettingsManager(dir)
|
||||||
|
mm := NewModlistManager(filepath.Join(dir, "modlists"))
|
||||||
|
cm := NewConfigManager(filepath.Join(dir, "cfg"))
|
||||||
|
streamer := NewLogStreamer()
|
||||||
|
|
||||||
|
pm := NewProcessManager(dir, modsDir, filepath.Join(dir, "cfg"), filepath.Join(dir, "profiles"), sm, mm, cm, streamer)
|
||||||
|
|
||||||
|
ml, _ := mm.Create("Test List")
|
||||||
|
mm.Update(ml.ID, "Test List", []models.ModEntry{
|
||||||
|
{Name: "CBA_A3", Enabled: true},
|
||||||
|
})
|
||||||
|
|
||||||
|
got := pm.buildModPath(ml.ID, "linux")
|
||||||
|
if strings.Contains(got, "Z:") {
|
||||||
|
t.Errorf("unexpected Z: prefix in args: %q", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestStartAndStopWithStub(t *testing.T) {
|
func TestStartAndStopWithStub(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
serverfileDir := filepath.Join(dir, "server")
|
serverfileDir := filepath.Join(dir, "server")
|
||||||
|
|||||||
@@ -14,6 +14,5 @@ services:
|
|||||||
- CFG_DIR=/servers/cfg
|
- CFG_DIR=/servers/cfg
|
||||||
- PROFILES_DIR=/servers/profiles
|
- PROFILES_DIR=/servers/profiles
|
||||||
- LISTEN=:8080
|
- LISTEN=:8080
|
||||||
- FRONTEND_DIR=/usr/share/arma3-web-server/frontend
|
|
||||||
- GIN_MODE=release
|
- GIN_MODE=release
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
Reference in New Issue
Block a user