From f7c8571f468e87aeb8fa4658ac8129d8517ee778 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 15 Aug 2021 16:46:55 -0700 Subject: [PATCH] Fix race condition when setting app name in console output --- server/console.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/console.go b/server/console.go index 908673e..d5babaa 100644 --- a/server/console.go +++ b/server/console.go @@ -19,6 +19,8 @@ import ( // a server. var appName string +var appNameSync sync.Once + var ErrTooMuchConsoleData = errors.New("console is outputting too much data") type ConsoleThrottler struct { @@ -131,9 +133,9 @@ func (s *Server) Throttler() *ConsoleThrottler { // PublishConsoleOutputFromDaemon sends output to the server console formatted // to appear correctly as being sent from Wings. func (s *Server) PublishConsoleOutputFromDaemon(data string) { - if appName == "" { + appNameSync.Do(func() { appName = config.Get().AppName - } + }) s.Events().Publish( ConsoleOutputEvent, colorstring.Color(fmt.Sprintf("[yellow][bold][%s Daemon]:[default] %s", appName, data)),