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:
38
config.go
Normal file
38
config.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user