Skip to content

Commit 17c8531

Browse files
fix runfile loading & improve logging noise
1 parent 6e205d4 commit 17c8531

9 files changed

Lines changed: 38 additions & 23 deletions

File tree

src/api/handlers.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ func HandleRunSteamCMD(w http.ResponseWriter, r *http.Request) {
3030
http.Error(w, "Only GET requests are allowed", http.StatusMethodNotAllowed)
3131
return
3232
}
33-
34-
logger.Core.Info("Running SteamCMD")
3533
_, err := steamcmd.InstallAndRunSteamCMD()
3634

3735
// Update last execution time

src/api/pages/TwoBoxForm.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func ServeTwoBoxFormTemplate(w http.ResponseWriter, r *http.Request) {
129129
SecondaryLabelType: "hidden",
130130
SubmitButtonText: localization.GetString("UIText_PlsRead_SubmitButton"),
131131
SkipButtonText: localization.GetString("UIText_PlsRead_SkipButton"),
132-
NextStep: "game_branch",
132+
NextStep: "admin_account",
133133
},
134134
"game_branch": {
135135
ID: "game_branch",
@@ -364,11 +364,14 @@ func ServeTwoBoxFormTemplate(w http.ResponseWriter, r *http.Request) {
364364
data.Step = "welcome"
365365
}
366366
stepOrder := []string{
367-
"welcome", "pls_read", "game_branch", "server_name", "save_name", "world_id", "max_players",
368-
"server_password", "discord_enabled", "discord_token", "control_panel_channel", "save_channel",
369-
"log_channel", "connection_list_channel", "status_channel", "control_channel",
370-
"network_config_choice", "game_port", "update_port", "upnp_enabled",
371-
"local_ip_address", "admin_account", "finalize",
367+
"welcome", "pls_read",
368+
//"game_branch",
369+
//"server_name", "save_name", "world_id", "max_players",
370+
//"server_password", "discord_enabled", "discord_token", "control_panel_channel", "save_channel",
371+
//"log_channel", "connection_list_channel", "status_channel", "control_channel",
372+
//"network_config_choice", "game_port", "update_port", "upnp_enabled",
373+
//"local_ip_address",
374+
"admin_account", "finalize",
372375
}
373376
var stepSlice []Step
374377
for _, id := range stepOrder {

src/api/runfileapi/runfile.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ func HandleRunfileGroups(w http.ResponseWriter, r *http.Request) {
112112
}
113113

114114
groups := runfile.GetUIGroups()
115-
logger.Runfile.Info("fetched UI groups")
116115
writeJSONResponse(w, http.StatusOK, groups, "")
117116
}
118117

@@ -153,8 +152,6 @@ func HandleRunfileArgs(w http.ResponseWriter, r *http.Request) {
153152
for i, arg := range args {
154153
apiArgs[i] = toAPIGameArg(arg)
155154
}
156-
157-
logger.Runfile.Info(fmt.Sprintf("fetched args for group=%s", group))
158155
writeJSONResponse(w, http.StatusOK, apiArgs, "")
159156
}
160157

src/api/runfileapi/runfilegallery.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strconv"
77
"strings"
88

9+
"github.com/SteamServerUI/SteamServerUI/v7/src/core/loader"
910
"github.com/SteamServerUI/SteamServerUI/v7/src/logger"
1011
"github.com/SteamServerUI/SteamServerUI/v7/src/steamserverui/gallery"
1112
)
@@ -18,7 +19,6 @@ type response struct {
1819

1920
// GalleryHandler handles GET /api/v2/gallery
2021
func GalleryHandler(w http.ResponseWriter, r *http.Request) {
21-
logger.Runfile.Info("Handling GET /api/v2/gallery request")
2222
forceUpdate := strings.ToLower(r.URL.Query().Get("forceUpdate")) == "true"
2323

2424
runfiles, err := gallery.GetRunfileGallery(forceUpdate)
@@ -28,13 +28,12 @@ func GalleryHandler(w http.ResponseWriter, r *http.Request) {
2828
return
2929
}
3030

31-
logger.Runfile.Info("Returning " + strconv.Itoa(len(runfiles)) + " runfiles from gallery")
31+
logger.Runfile.Debug("Returning " + strconv.Itoa(len(runfiles)) + " runfiles from gallery")
3232
sendResponse(w, http.StatusOK, response{Data: runfiles})
3333
}
3434

3535
// GallerySelectHandler handles POST /api/v2/gallery/select
3636
func GallerySelectHandler(w http.ResponseWriter, r *http.Request) {
37-
logger.Runfile.Info("Handling POST /api/v2/gallery/select request")
3837

3938
var req struct {
4039
Identifier string `json:"identifier"`
@@ -57,7 +56,8 @@ func GallerySelectHandler(w http.ResponseWriter, r *http.Request) {
5756
return
5857
}
5958

60-
logger.Runfile.Info("Successfully saved runfile " + req.Identifier)
59+
logger.Runfile.Debug("Successfully saved runfile " + req.Identifier)
60+
loader.ReloadBackend()
6161
sendResponse(w, http.StatusOK, response{Data: "Runfile " + req.Identifier + " saved"})
6262
}
6363

src/core/loader/loader.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func ReloadBackend() {
3737

3838
logger.Core.Info("Reloading backend...")
3939
ReloadConfig()
40+
ReloadRunfile()
4041
ReloadBepInEx()
4142
//ReloadStationeersBackupManager()
4243
ReloadLocalizer()

src/core/loader/runfile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ func InitRunfile(game string) error {
1919
return fmt.Errorf("game cannot be empty")
2020
}
2121

22-
logger.Runfile.Info("Updating runfile game to " + game)
23-
logger.Runfile.Info("Stopping server if running")
22+
logger.Runfile.Debug("Updating runfile game to " + game)
23+
logger.Runfile.Debug("Stopping server if running")
2424
gamemgr.InternalStopServer()
2525
config.SetRunfileIdentifier(game)
2626

src/steamcmd/steamcmd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ func runSteamCMD(steamCMDDir string) (int, error) {
122122
cmd.Env = newEnv
123123
}
124124

125+
if config.GetSkipSteamCMD() {
126+
logger.Install.Warn("Skipping SteamCMD installation")
127+
return 0, nil
128+
}
129+
125130
// Run the command
126131
if config.GetLogLevel() == 10 {
127132
cmdString := strings.Join(cmd.Args, " ")

src/steamserverui/gallery/gallery.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"sync"
1212

1313
"github.com/SteamServerUI/SteamServerUI/v7/src/config"
14+
"github.com/SteamServerUI/SteamServerUI/v7/src/core/loader"
1415
"github.com/SteamServerUI/SteamServerUI/v7/src/logger"
1516
)
1617

@@ -44,7 +45,7 @@ func GetRunfileGallery(forceUpdate bool) ([]GalleryRunfile, error) {
4445

4546
// Fetch manifest from GitHub Pages
4647
const manifestURL = "https://steamserverui.github.io/runfiles/manifest.ssui"
47-
logger.Runfile.Info("Fetching runfile gallery from " + manifestURL)
48+
logger.Runfile.Debug("Fetching runfile gallery from " + manifestURL)
4849
resp, err := http.Get(manifestURL)
4950
if err != nil {
5051
logger.Runfile.Error(fmt.Sprintf("Failed to fetch manifest: %v", err))
@@ -92,7 +93,7 @@ func SaveRunfileToDisk(identifier string) error {
9293
baseURL := "https://steamserverui.github.io/runfiles"
9394
fileURL := fmt.Sprintf("%s/%s", baseURL, filename)
9495

95-
logger.Runfile.Info("Fetching runfile from " + fileURL)
96+
logger.Runfile.Debug("Fetching runfile from " + fileURL)
9697
resp, err := http.Get(fileURL)
9798
if err != nil {
9899
logger.Runfile.Error(fmt.Sprintf("Failed to fetch runfile %s: %v", filename, err))
@@ -106,7 +107,16 @@ func SaveRunfileToDisk(identifier string) error {
106107
}
107108

108109
saveFilePath := filepath.Join(config.GetRunfilesFolder(), filename)
109-
logger.Runfile.Info("Saving runfile to " + saveFilePath)
110+
logger.Runfile.Debug("Saving runfile to " + saveFilePath)
111+
112+
// get the dir of the saveFilePath, and os.MkdirAll it if it doesn't exist
113+
dir := filepath.Dir(saveFilePath)
114+
if _, err := os.Stat(dir); os.IsNotExist(err) {
115+
if err := os.MkdirAll(dir, 0755); err != nil {
116+
logger.Runfile.Error(fmt.Sprintf("Failed to create runfiles directory %s: %v", dir, err))
117+
return fmt.Errorf("couldn't create directory")
118+
}
119+
}
110120

111121
// Create or overwrite the file
112122
file, err := os.Create(saveFilePath)
@@ -122,7 +132,8 @@ func SaveRunfileToDisk(identifier string) error {
122132
return fmt.Errorf("couldn't save %s, disk's being dramatic", filename)
123133
}
124134

125-
logger.Runfile.Info("Successfully saved runfile " + filename)
135+
logger.Runfile.Debug("Successfully saved runfile " + filename)
136+
loader.InitRunfile(identifier)
126137
return nil
127138
}
128139

src/steamserverui/runfile/args.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func LoadRunfile(gameName, runFilesFolder string) error {
222222
}
223223

224224
CurrentRunfile = &runfile
225-
logger.Runfile.Info(fmt.Sprintf("runfile loaded: path=%s", filePath))
225+
logger.Runfile.Debug(fmt.Sprintf("runfile loaded: path=%s", filePath))
226226
return nil
227227
}
228228

@@ -276,7 +276,7 @@ func SaveRunfile() error {
276276
break
277277
}
278278

279-
logger.Runfile.Info(fmt.Sprintf("runfile saved: path=%s", filePath))
279+
logger.Runfile.Debug(fmt.Sprintf("runfile saved: path=%s", filePath))
280280
return nil
281281
}
282282

0 commit comments

Comments
 (0)