From 163a540d46bf894f71cc127e6efc875733a67fc7 Mon Sep 17 00:00:00 2001 From: Mo Firouz Date: Tue, 14 Mar 2017 20:38:41 +0000 Subject: [PATCH] Fix regression loading config file. #48 --- CHANGELOG.md | 3 +++ main.go | 23 ++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb6dbd2194..248e14bbb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ The format is based on [keep a changelog](http://keepachangelog.com/) and this p ### Changed - The build system now strips up to current dir in recorded source file paths at compile. +### Fixed +- Fix regression loading config file. + ## [0.11.3] - 2017-02-25 ### Added - Add CORS headers for browser games. diff --git a/main.go b/main.go index a39a9023f8..e406d66d45 100644 --- a/main.go +++ b/main.go @@ -156,21 +156,22 @@ func parseArgs(clogger zap.Logger) server.Config { var opsPort int flags.IntVar(&opsPort, "ops-port", -1, "Set port for ops dashboard.") - if len(filepath) > 0 { - data, err := ioutil.ReadFile(filepath) - if err != nil { - clogger.Error("Could not read config file, using defaults", zap.Error(err)) - } else { - err = yaml.Unmarshal([]byte(data), config) + if err := flags.Parse(os.Args[1:]); err != nil { + clogger.Error("Could not parse command line arguments - ignoring command-line overrides", zap.Error(err)) + } else { + + if len(filepath) > 0 { + data, err := ioutil.ReadFile(filepath) if err != nil { - clogger.Error("Could not parse config file, using defaults", zap.Error(err)) + clogger.Error("Could not read config file, using defaults", zap.Error(err)) + } else { + err = yaml.Unmarshal(data, config) + if err != nil { + clogger.Error("Could not parse config file, using defaults", zap.Error(err)) + } } } - } - if err := flags.Parse(os.Args[1:]); err != nil { - clogger.Error("Could not parse command line arguments - ignoring command-line overrides", zap.Error(err)) - } else { if len(name) > 0 { config.Name = name }