wings/server/config_parser.go

34 lines
847 B
Go
Raw Normal View History

package server
import (
2019-12-01 05:46:54 +00:00
"github.com/pterodactyl/wings/parser"
"sync"
)
// Parent function that will update all of the defined configuration files for a server
// automatically to ensure that they always use the specified values.
func (s *Server) UpdateConfigurationFiles() {
wg := new(sync.WaitGroup)
files := s.ProcessConfiguration().ConfigurationFiles
for _, v := range files {
wg.Add(1)
2019-12-01 05:46:54 +00:00
go func(f parser.ConfigurationFile, server *Server) {
defer wg.Done()
2020-06-13 17:26:35 +00:00
p, err := server.Filesystem.SafePath(f.FileName)
if err != nil {
2020-06-13 17:26:35 +00:00
server.Log().WithField("error", err).Error("failed to generate safe path for configuration file")
return
}
if err := f.Parse(p, false); err != nil {
2020-06-13 17:26:35 +00:00
server.Log().WithField("error", err).Error("failed to parse and update server configuration file")
}
2019-12-01 05:46:54 +00:00
}(v, s)
}
wg.Wait()
}