diff --git a/config/config.go b/config/config.go index 7599ae1..9c2b1ef 100644 --- a/config/config.go +++ b/config/config.go @@ -250,12 +250,17 @@ func ReadConfiguration(path string) (*Configuration, error) { } var _config *Configuration +var _debugViaFlag bool // Set the global configuration instance. func Set(c *Configuration) { _config = c } +func SetDebugViaFlag(d bool) { + _debugViaFlag = d +} + // Get the global configuration instance. func Get() *Configuration { return _config @@ -383,7 +388,14 @@ func (c *Configuration) WriteToDisk() error { } defer f.Close() - b, err := yaml.Marshal(&c) + ccopy := *c + // If debugging is set with the flag, don't save that to the configuration file, otherwise + // you'll always end up in debug mode. + if _debugViaFlag { + ccopy.Debug = false + } + + b, err := yaml.Marshal(&ccopy) if err != nil { return err } diff --git a/wings.go b/wings.go index 44b8357..706f512 100644 --- a/wings.go +++ b/wings.go @@ -15,11 +15,14 @@ import ( "os" ) +var configPath = "config.yml" +var debug = false + // Entrypoint for the Wings application. Configures the logger and checks any // flags that were passed through in the boot arguments. func main() { - var configPath = *flag.String("config", "config.yml", "set the location for the configuration file") - var debug = *flag.Bool("debug", false, "pass in order to run wings in debug mode") + flag.StringVar(&configPath, "config", "config.yml", "set the location for the configuration file") + flag.BoolVar(&debug, "debug", false, "pass in order to run wings in debug mode") flag.Parse() @@ -49,6 +52,7 @@ func main() { } config.Set(c) + config.SetDebugViaFlag(debug) zap.S().Infof("checking for pterodactyl system user \"%s\"", c.System.User) if su, err := c.EnsurePterodactylUser(); err != nil {