diff --git a/frontend/src/pages/server/Administration.tsx b/frontend/src/pages/server/Administration.tsx index d6f7223..64f7508 100644 --- a/frontend/src/pages/server/Administration.tsx +++ b/frontend/src/pages/server/Administration.tsx @@ -10,12 +10,12 @@ import { TabPanel, Typography } from "@mui/joy"; -import {PasswordInput} from "../../components/PasswordInput"; import React, {useState} from "react"; import {DeleteProfile, DeleteServerFiles} from "../../../wailsjs/go/server/ServerController"; import {server} from "../../../wailsjs/go/models"; import {useAlert} from "../../components/AlertProvider"; -import {IconAlertCircleFilled} from "@tabler/icons-react"; +import {IconAlertCircleFilled, IconInfoCircle} from "@tabler/icons-react"; +import {GetServerStartupCommand} from "../../../wailsjs/go/server/ServerController"; type Props = { setServ: React.Dispatch> @@ -29,6 +29,8 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) { const [deleteServerFilesModalOpen, setDeleteServerFilesModalOpen] = useState(false) const [deleteProfileModalOpen, setDeleteProfileModalOpen] = useState(false) const [deleteEverythingModalOpen, setDeleteEverythingModalOpen] = useState(false) + const [showServerCommandModalOpen, setShowServerCommandModalOpen] = useState(false) + const [serverCommand, setServerCommand] = useState(""); const {addAlert} = useAlert(); @@ -44,8 +46,6 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) { DeleteServerFiles(serv.id).then(() => DeleteProfile(serv.id)).then(() => {addAlert("Deleted everything", "success"); location.reload()}).catch((err) => {console.error(err); addAlert(err, "danger")}) } - - return ( @@ -127,9 +127,44 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) { - - Server startup - +
+ + Server startup + + +
+
+ setShowServerCommandModalOpen(false)}> + + + + Server startup command + + + + {serverCommand} + + + + + + + +
+
+
+
diff --git a/server/server.go b/server/server.go index acb67a8..8c40245 100644 --- a/server/server.go +++ b/server/server.go @@ -79,10 +79,7 @@ func (s *Server) Start() error { if s.IsServerRunning() { return fmt.Errorf("error starting server: server is already running") } else { - - args := s.CreateArguments() - - s.Command = exec.Command(path.Join(s.ServerPath, "ShooterGame\\Binaries\\Win64\\ArkAscendedServer.exe"), args...) + s.Command = s.CreateServerCmd() err = s.Command.Start() if err != nil { return fmt.Errorf("error starting server: %v", err) @@ -111,6 +108,12 @@ func (s *Server) Start() error { return nil } +// CreateServerCmd returns the command to start the server +func (s *Server) CreateServerCmd() *exec.Cmd { + args := s.CreateArguments() + return exec.Command(path.Join(s.ServerPath, "ShooterGame\\Binaries\\Win64\\ArkAscendedServer.exe"), args...) +} + // ForceStop forces the server to stop "quitting/killing the process" func (s *Server) ForceStop() error { diff --git a/server/server_controller.go b/server/server_controller.go index 90b4af1..84b7ddc 100644 --- a/server/server_controller.go +++ b/server/server_controller.go @@ -493,3 +493,13 @@ func (c *ServerController) CheckServerInstalled(id int) (bool, error) { } //endregion + +func (c *ServerController) GetServerStartupCommand(id int) (string, error) { + server, err := c.GetServerWithError(id, false) + if err != nil { + err := fmt.Errorf("error getting server startup command " + strconv.Itoa(id) + ": server does not exist") + runtime.LogError(c.ctx, err.Error()) + return "error getting server startup command " + strconv.Itoa(id) + ": server does not exist", err + } + return server.CreateServerCmd().String(), nil +}