File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
1111
1212 "github.com/JacksonTheMaster/StationeersServerUI/v5/src/config"
1313 "github.com/JacksonTheMaster/StationeersServerUI/v5/src/logger"
14+ "github.com/JacksonTheMaster/StationeersServerUI/v5/src/managers/gamemgr"
1415)
1516
1617// runAndExit launches the new executable and terminates the current process
@@ -61,7 +62,13 @@ func runAndExitLinux(newExe string) error {
6162 return nil
6263}
6364
64- func RestartMySelf () {
65+ func RestartMySelf () { // Stop the game server before restarting to prevent detached processes
66+ if config .GetIsGameServerRunning () {
67+ logger .Install .Info ("🛑 Stopping game server before restart..." )
68+ if err := gamemgr .InternalStopServer (); err != nil {
69+ logger .Install .Warn (fmt .Sprintf ("⚠️ Failed to stop game server before restart: %v. Proceeding anyway." , err ))
70+ }
71+ }
6572 currentExe , err := os .Executable ()
6673 if err != nil {
6774 logger .Install .Warn (fmt .Sprintf ("⚠️ Restart failed: couldn’t get current executable path: %v. Keeping version %s." , err , config .GetVersion ()))
Original file line number Diff line number Diff line change 99
1010 "github.com/JacksonTheMaster/StationeersServerUI/v5/src/config"
1111 "github.com/JacksonTheMaster/StationeersServerUI/v5/src/logger"
12+ "github.com/JacksonTheMaster/StationeersServerUI/v5/src/managers/gamemgr"
1213)
1314
1415// githubRelease represents the structure of a GitHub release response
@@ -112,6 +113,14 @@ func Update(isInUpdateableState bool) (err error, newVersion string) {
112113 }
113114 }
114115
116+ // Stop the game server before launching the new version to prevent detached processes
117+ if config .GetIsGameServerRunning () {
118+ logger .Install .Info ("🛑 Stopping game server before applying update..." )
119+ if err := gamemgr .InternalStopServer (); err != nil {
120+ logger .Install .Warn (fmt .Sprintf ("⚠️ Failed to stop game server before update: %v. Proceeding anyway." , err ))
121+ }
122+ }
123+
115124 // Launch the new executable and exit
116125 logger .Install .Info ("🚀 Launching the new version and retiring the old one..." )
117126 if runtime .GOOS == "windows" {
You can’t perform that action at this time.
0 commit comments