Fixes Changes and new additions

Fixed an issue where launching server w/o screen failed
New: added an output showing screen sessions after launching
New: added stdout and stdin to screenless launch allowing interacting with server cli
Change: Broke up source code to make it easier to read and make changes
Change: Updated .gitignore
This commit is contained in:
2026-01-13 10:51:18 -07:00
parent 3406ab4743
commit b2c534f29b
7 changed files with 134 additions and 111 deletions

38
config.go Normal file
View File

@@ -0,0 +1,38 @@
package main
import (
"log"
"os"
"gopkg.in/yaml.v3"
)
const fmConfig = "config.yml"
type GoConfig struct {
Config struct {
ServDir string `yaml:"serverFolder"`
ServPort int `yaml:"port"`
WorldFile string `yaml:"worldFile"`
ServCfg string `yaml:"serverSettings"`
ServExec string `yaml:"serverExec"`
BackupDir string `yaml:"backupDir"`
UseScreen bool `yaml:"screen"`
ScreenName string `yaml:"screenName"`
} `yaml:"server"`
}
func readCfg(factCfg string) GoConfig {
//read config file (YAML)
fileBytes, err := os.ReadFile(factCfg)
if err != nil {
log.Fatalf("Error reading config file: %v", err)
}
// return Struct
var config GoConfig
err = yaml.Unmarshal(fileBytes, &config)
if err != nil {
log.Fatalf("Error unmarshalling YAML file: %v", err)
}
return config
}