[#3896bk] Configure base support for properties file parsing
This commit is contained in:
33
server/config_parser.go
Normal file
33
server/config_parser.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"go.uber.org/zap"
|
||||
"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)
|
||||
|
||||
for _, v := range s.processConfiguration.ConfigurationFiles {
|
||||
wg.Add(1)
|
||||
|
||||
go func(server *Server) {
|
||||
defer wg.Done()
|
||||
|
||||
p, err := s.Filesystem.SafePath(v.FileName)
|
||||
if err != nil {
|
||||
zap.S().Errorw("failed to generate safe path for configuration file", zap.String("server", server.Uuid), zap.Error(err))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if err := v.Parse(p); err != nil {
|
||||
zap.S().Errorw("failed to parse and update server configuration file", zap.String("server", server.Uuid), zap.Error(err))
|
||||
}
|
||||
}(s)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
@@ -261,6 +261,13 @@ func (d *DockerEnvironment) Start() error {
|
||||
}
|
||||
}
|
||||
|
||||
// Update the configuration files defined for the server before beginning the boot process.
|
||||
// This process executes a bunch of parallel updates, so we just block until that process
|
||||
// is completed. Any errors as a result of this will just be bubbled out in the logger,
|
||||
// we don't need to actively do anything about it at this point, worst comes to worst the
|
||||
// server starts in a weird state and the user can manually adjust.
|
||||
d.Server.UpdateConfigurationFiles()
|
||||
|
||||
// Reset the permissions on files for the server before actually trying
|
||||
// to start it.
|
||||
if err := d.Server.Filesystem.Chown("/"); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user