File tree Expand file tree Collapse file tree 1 file changed +21
-9
lines changed
Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change 77 "path/filepath"
88 "runtime"
99 "strings"
10+ "sync"
1011)
1112
1213// customLogDir is used to override the default log directory, e.g. for testing.
@@ -87,19 +88,30 @@ func LoadAllConfigs() ([]SiteConfig, error) {
8788 }
8889
8990 var configs []SiteConfig
91+ var mu sync.Mutex
92+ var wg sync.WaitGroup
93+
9094 for _ , file := range files {
9195 if filepath .Ext (file .Name ()) == ".json" {
92- conf , err := LoadConfig (filepath .Join (configDir , file .Name ()))
93- if err != nil {
94- fmt .Printf ("Error loading config %s: %v\n " , file .Name (), err )
95- continue
96- }
97- configs = append (configs , conf )
98-
99- // Populate the global SiteConfigs map
100- SiteConfigs [conf .Domain ] = conf
96+ wg .Add (1 )
97+ go func (fname string ) {
98+ defer wg .Done ()
99+
100+ conf , err := LoadConfig (filepath .Join (configDir , fname ))
101+ if err != nil {
102+ fmt .Printf ("Error loading config %s: %v\n " , fname , err )
103+ return
104+ }
105+
106+ mu .Lock ()
107+ configs = append (configs , conf )
108+ SiteConfigs [conf .Domain ] = conf
109+ mu .Unlock ()
110+ }(file .Name ())
101111 }
102112 }
113+
114+ wg .Wait ()
103115 return configs , nil
104116}
105117
You can’t perform that action at this time.
0 commit comments