cmd: Persists config file right before starting the server
Tests would fail because the config file is polled in order to check
if the server is already started or not. Moving the persist command
right before starting the server resolves issues with racy tests.
@@ -94,12 +94,6 @@ func RunHost(c *config.Config) func(cmd *cobra.Command, args []string) {
c.ClusterURL = fmt.Sprintf("%s://%s:%d", proto, host, c.BindPort)
}
- if ok, _ := cmd.Flags().GetBool("dangerous-auto-logon"); ok {
- logger.Warnln("Do not use flag --dangerous-auto-logon in production.")
- err := c.Persist()
- pkg.Must(err, "Could not write configuration file: %s", err)
- }
-
n := negroni.New()
if ok, _ := cmd.Flags().GetBool("disable-telemetry"); !ok && os.Getenv("DISABLE_TELEMETRY") != "1" {
@@ -122,6 +116,12 @@ func RunHost(c *config.Config) func(cmd *cobra.Command, args []string) {
},
})
+ if ok, _ := cmd.Flags().GetBool("dangerous-auto-logon"); ok {
+ logger.Warnln("Do not use flag --dangerous-auto-logon in production.")
+ err := c.Persist()
+ pkg.Must(err, "Could not write configuration file: %s", err)
+ }
+
err := graceful.Graceful(func() error {
var err error
logger.Infof("Setting up http server on %s", c.GetAddress())
