Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Add start with application option #118

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions frontend/src/pages/server/Administration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ function ServerStartupCard({setServ, serv}: {setServ: React.Dispatch<React.SetSt
convertValues: p.convertValues
}))}/><br/>
{/*<Checkbox label="Restart server on server quit" checked={serv?.restartOnServerQuit} onChange={(e) => setServ((p) => ({ ...p, restartOnServerQuit: e.target.checked }))} />*/}
<Checkbox label="Start server when application opens" checked={serv?.startWithApplication}
onChange={(e) => setServ((p) => ({
...p,
startWithApplication: e.target.checked,
convertValues: p.convertValues
}))}/><br/>

<FormLabel>Custom server "dash" arguments (only use args like: -EnableIdlePlayerKick
-ForceAllowCaveFlyers)</FormLabel>
Expand Down
11 changes: 7 additions & 4 deletions server/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package server

import (
"fmt"
"github.com/JensvandeWiel/ArkAscendedServerManager/helpers"
"github.com/go-ini/ini"
"github.com/sethvargo/go-password/password"
"github.com/wailsapp/wails/v2/pkg/runtime"
"io"
"net"
"os"
"path/filepath"
"strconv"

"github.com/JensvandeWiel/ArkAscendedServerManager/helpers"
"github.com/go-ini/ini"
"github.com/sethvargo/go-password/password"
"github.com/wailsapp/wails/v2/pkg/runtime"
)

var iniOpts = ini.LoadOptions{
Expand Down Expand Up @@ -77,6 +78,8 @@ func generateNewDefaultServer(id int) Server {

ServerMap: "TheIsland_WP",
MaxPlayers: 70,

StartWithApplication: false,
}
}

Expand Down
3 changes: 3 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ type Server struct {

ServerMap string `json:"serverMap"`
MaxPlayers int `json:"maxPlayers"`

StartWithApplication bool `json:"startWithApplication"`
}

// UpdateConfig updates the configuration files for the server e.g.: GameUserSettings.ini
Expand Down Expand Up @@ -96,6 +98,7 @@ func (s *Server) UpdateConfig() error {

//TODO Add configuration parsing/loading/saving for server specific files
//TODO Add startup arguments parsing
//TODO Add check for running application (ensures no accidental duplicated servers, especially with addition of start with application)

func (s *Server) Start() error {

Expand Down
19 changes: 19 additions & 0 deletions server/server_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ func (c *ServerController) Startup(ctx context.Context) {
}

c.serverDir = serverDir

c.StartServersWithApplication()
}

func (c *ServerController) StartServersWithApplication() {
servers, err := c.getAllServers()
if err != nil {
newErr := fmt.Errorf("Error getting all servers " + err.Error())
runtime.LogErrorf(c.ctx, newErr.Error())
return
}

for id := range servers {
server := c.Servers[id]
runtime.LogInfof(c.ctx, "StartWithApplication: %t", server.StartWithApplication)
if server.StartWithApplication {
c.StartServer(server.Id)
}
}
}

//endregion
Expand Down
Loading