From df886b3f00b73dcb6b21e48dc677e54d0c9da8f3 Mon Sep 17 00:00:00 2001 From: Jens van de Wiel Date: Fri, 3 Nov 2023 14:09:22 +0100 Subject: [PATCH 1/5] added custom args --- frontend/src/pages/server/Administration.tsx | 5 ++++- server/helpers.go | 3 +++ server/server.go | 9 ++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/server/Administration.tsx b/frontend/src/pages/server/Administration.tsx index fea9db7..ffac3af 100644 --- a/frontend/src/pages/server/Administration.tsx +++ b/frontend/src/pages/server/Administration.tsx @@ -46,7 +46,6 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) { - return ( @@ -136,6 +135,10 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) {
setServ((p) => ({ ...p, disableUpdateOnStart: e.target.checked }))} /> + Custom server "dash" arguments (only use args like: -EnableIdlePlayerKick -ForceAllowCaveFlyers) + setServ((p) => ({ ...p, extraDashArgs: e.target.value }))}> + Custom server "questionmark" arguments (only use args like: ?PreventSpawnAnimations=true?PreventTribeAlliances=true) + setServ((p) => ({ ...p, extraQuestionmarkArguments: e.target.value }))}>
diff --git a/server/helpers.go b/server/helpers.go index 4336270..4ff36ed 100644 --- a/server/helpers.go +++ b/server/helpers.go @@ -45,6 +45,9 @@ func generateNewDefaultServer(id int) Server { DisableUpdateOnStart: false, + ExtraQuestionmarkArguments: "", + ExtraDashArgs: "", + ServerAlias: "Server " + strconv.Itoa(id), ServerName: "A server managed by ArkAscendedServerManager", diff --git a/server/server.go b/server/server.go index 3d5698a..35d174f 100644 --- a/server/server.go +++ b/server/server.go @@ -26,6 +26,9 @@ type Server struct { //CONFIGURATION VARIABLES + ExtraDashArgs string `json:"extraDashArgs"` + ExtraQuestionmarkArguments string `json:"extraQuestionmarkArguments"` + // Id is the id of the server Id int `json:"id"` @@ -152,7 +155,11 @@ func (s *Server) CreateArguments() string { basePrompt += "?QueryPort=" + strconv.Itoa(s.QueryPort) basePrompt += "?RCONEnabled=true?RCONServerGameLogBuffer=600?RCONPort=" + strconv.Itoa(s.RCONPort) basePrompt += "?MaxPlayers=" + strconv.Itoa(s.MaxPlayers) - basePrompt += "?ServerAdminPassword=" + s.AdminPassword + basePrompt += s.ExtraQuestionmarkArguments + //TODO move AdminPassword to ini + basePrompt += "?ServerAdminPassword=" + s.AdminPassword + "?" + + basePrompt += " " + s.ExtraDashArgs return basePrompt } From 5ee6dfd4bb7d2779ed5a69dbca63611f1d658574 Mon Sep 17 00:00:00 2001 From: Jens van de Wiel Date: Fri, 3 Nov 2023 16:14:03 +0100 Subject: [PATCH 2/5] added way to add mods --- frontend/src/pages/Server.tsx | 5 ++- frontend/src/pages/server/Administration.tsx | 2 +- frontend/src/pages/server/Settings.tsx | 41 ++++++++++++++++++++ server/helpers.go | 2 + server/server.go | 5 +++ 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 frontend/src/pages/server/Settings.tsx diff --git a/frontend/src/pages/Server.tsx b/frontend/src/pages/Server.tsx index 5feae43..54c3c26 100644 --- a/frontend/src/pages/Server.tsx +++ b/frontend/src/pages/Server.tsx @@ -31,6 +31,7 @@ import {Console} from "./server/Console"; import {UpdaterModal} from "./UpdaterModal"; import {InstallUpdateVerify} from "../../wailsjs/go/installer/InstallerController"; import {SendRconCommand} from "../../wailsjs/go/helpers/HelpersController"; +import {Settings} from "./server/Settings"; type Props = { @@ -185,11 +186,13 @@ export const Server = ({id, className}: Props) => { Console - General + General Settings + Server Settings Administration + CheckServerInstalled(serv.id).then((val) => setIsInstalled(val)).catch((reason) => console.error(reason))}/> ) : ( setIsInstalled(true)}/>)} diff --git a/frontend/src/pages/server/Administration.tsx b/frontend/src/pages/server/Administration.tsx index ffac3af..198119f 100644 --- a/frontend/src/pages/server/Administration.tsx +++ b/frontend/src/pages/server/Administration.tsx @@ -47,7 +47,7 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) { return ( - + Server Administration diff --git a/frontend/src/pages/server/Settings.tsx b/frontend/src/pages/server/Settings.tsx new file mode 100644 index 0000000..f7492f4 --- /dev/null +++ b/frontend/src/pages/server/Settings.tsx @@ -0,0 +1,41 @@ +import React from "react"; +import {server} from "../../../wailsjs/go/models"; +import { + Button, + Card, Checkbox, + DialogActions, + DialogContent, + DialogTitle, + Divider, FormLabel, Input, + Modal, + ModalDialog, + TabPanel, + Typography +} from "@mui/joy"; +import {IconAlertCircleFilled} from "@tabler/icons-react"; + +type Props = { + setServ: React.Dispatch> + serv: server.Server; + +} + +export function Settings({setServ, serv}: Props) { + return ( + + + + Mods + + + +
+
+ Mods (e.g.: modid1,modid2,modid3) + setServ((p) => ({ ...p, mods: e.target.value }))}> +
+
+
+
+ ); +} \ No newline at end of file diff --git a/server/helpers.go b/server/helpers.go index 4ff36ed..aa5d345 100644 --- a/server/helpers.go +++ b/server/helpers.go @@ -48,6 +48,8 @@ func generateNewDefaultServer(id int) Server { ExtraQuestionmarkArguments: "", ExtraDashArgs: "", + Mods: "", + ServerAlias: "Server " + strconv.Itoa(id), ServerName: "A server managed by ArkAscendedServerManager", diff --git a/server/server.go b/server/server.go index 35d174f..2007196 100644 --- a/server/server.go +++ b/server/server.go @@ -29,6 +29,8 @@ type Server struct { ExtraDashArgs string `json:"extraDashArgs"` ExtraQuestionmarkArguments string `json:"extraQuestionmarkArguments"` + Mods string `json:"mods"` + // Id is the id of the server Id int `json:"id"` @@ -159,6 +161,9 @@ func (s *Server) CreateArguments() string { //TODO move AdminPassword to ini basePrompt += "?ServerAdminPassword=" + s.AdminPassword + "?" + if s.Mods != "" { + basePrompt += " -mods=" + s.Mods + } basePrompt += " " + s.ExtraDashArgs return basePrompt From bffcb09c2c86a017c9ba01cf13a6ea70ee2c922d Mon Sep 17 00:00:00 2001 From: Jens van de Wiel Date: Fri, 3 Nov 2023 16:22:40 +0100 Subject: [PATCH 3/5] hide general settings page for now --- frontend/src/pages/Server.tsx | 4 ++-- frontend/src/pages/server/Administration.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/Server.tsx b/frontend/src/pages/Server.tsx index 54c3c26..d33e1a0 100644 --- a/frontend/src/pages/Server.tsx +++ b/frontend/src/pages/Server.tsx @@ -187,12 +187,12 @@ export const Server = ({id, className}: Props) => { Console General Settings - Server Settings + {/*Server Settings*/} Administration - + {/**/} CheckServerInstalled(serv.id).then((val) => setIsInstalled(val)).catch((reason) => console.error(reason))}/> ) : ( setIsInstalled(true)}/>)}
diff --git a/frontend/src/pages/server/Administration.tsx b/frontend/src/pages/server/Administration.tsx index 198119f..ffac3af 100644 --- a/frontend/src/pages/server/Administration.tsx +++ b/frontend/src/pages/server/Administration.tsx @@ -47,7 +47,7 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) { return ( - + Server Administration From c4174fb7cecaa20aaa3496de256a4e8192450e1d Mon Sep 17 00:00:00 2001 From: Jens van de Wiel Date: Fri, 3 Nov 2023 16:30:05 +0100 Subject: [PATCH 4/5] added restartonserverquit backend --- server/helpers.go | 1 + server/server.go | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/server/helpers.go b/server/helpers.go index aa5d345..b0c780e 100644 --- a/server/helpers.go +++ b/server/helpers.go @@ -44,6 +44,7 @@ func generateNewDefaultServer(id int) Server { Id: id, DisableUpdateOnStart: false, + RestartOnServerQuit: true, ExtraQuestionmarkArguments: "", ExtraDashArgs: "", diff --git a/server/server.go b/server/server.go index 2007196..a84f99d 100644 --- a/server/server.go +++ b/server/server.go @@ -23,6 +23,7 @@ type Server struct { //PREFERENCES DisableUpdateOnStart bool `json:"disableUpdateOnStart"` + RestartOnServerQuit bool `json:"restartOnServerQuit"` //CONFIGURATION VARIABLES @@ -85,9 +86,21 @@ func (s *Server) Start() error { } runtime.EventsEmit(s.ctx, "onServerStart", s.Id) go func() { - _ = s.Command.Wait() + err := s.Command.Wait() runtime.EventsEmit(s.ctx, "onServerExit", s.Id) + + //restart server on crash + if err != nil && s.RestartOnServerQuit { + code := s.Command.ProcessState.ExitCode() + if code != 0 { + err := s.Start() + if err != nil { + runtime.EventsEmit(s.ctx, "onRestartServerFailed", err) + } + } + } + }() } From 9f3ee7123f248d051d3f8017cb578d6f96a1a86d Mon Sep 17 00:00:00 2001 From: Jens van de Wiel Date: Fri, 3 Nov 2023 16:35:23 +0100 Subject: [PATCH 5/5] disabled restart --- frontend/src/pages/server/Administration.tsx | 4 +++- server/server.go | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/server/Administration.tsx b/frontend/src/pages/server/Administration.tsx index ffac3af..1ea1c3e 100644 --- a/frontend/src/pages/server/Administration.tsx +++ b/frontend/src/pages/server/Administration.tsx @@ -134,7 +134,9 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) {
- setServ((p) => ({ ...p, disableUpdateOnStart: e.target.checked }))} /> + setServ((p) => ({ ...p, disableUpdateOnStart: e.target.checked }))} />
+ {/* setServ((p) => ({ ...p, restartOnServerQuit: e.target.checked }))} />*/} + Custom server "dash" arguments (only use args like: -EnableIdlePlayerKick -ForceAllowCaveFlyers) setServ((p) => ({ ...p, extraDashArgs: e.target.value }))}> Custom server "questionmark" arguments (only use args like: ?PreventSpawnAnimations=true?PreventTribeAlliances=true) diff --git a/server/server.go b/server/server.go index a84f99d..94b7614 100644 --- a/server/server.go +++ b/server/server.go @@ -6,7 +6,6 @@ import ( "github.com/keybase/go-ps" "github.com/wailsapp/wails/v2/pkg/runtime" "os/exec" - "path" "strconv" ) @@ -86,20 +85,21 @@ func (s *Server) Start() error { } runtime.EventsEmit(s.ctx, "onServerStart", s.Id) go func() { - err := s.Command.Wait() + _ = s.Command.Wait() runtime.EventsEmit(s.ctx, "onServerExit", s.Id) - //restart server on crash + /*//restart server on crash if err != nil && s.RestartOnServerQuit { code := s.Command.ProcessState.ExitCode() + time.Sleep(2 * time.Second) if code != 0 { err := s.Start() if err != nil { runtime.EventsEmit(s.ctx, "onRestartServerFailed", err) } } - } + }*/ }() }