diff --git a/router/router_server.go b/router/router_server.go index a516005..87c0b67 100644 --- a/router/router_server.go +++ b/router/router_server.go @@ -135,7 +135,7 @@ func postServerInstall(c *gin.Context) { s := GetServer(c.Param("server")) go func(serv *server.Server) { - if err := serv.Install(); err != nil { + if err := serv.Install(true); err != nil { serv.Log().WithField("error", err).Error("failed to execute server installation process") } }(s) diff --git a/router/router_system.go b/router/router_system.go index 2e1ed13..27e8e10 100644 --- a/router/router_system.go +++ b/router/router_system.go @@ -59,7 +59,7 @@ func postCreateServer(c *gin.Context) { go func(i *installer.Installer) { i.Execute() - if err := i.Server().Install(); err != nil { + if err := i.Server().Install(false); err != nil { log.WithFields(log.Fields{"server": i.Uuid(), "error": err}).Error("failed to run install process for server") } }(install) diff --git a/server/install.go b/server/install.go index 99faadd..6a7805e 100644 --- a/server/install.go +++ b/server/install.go @@ -25,7 +25,17 @@ import ( // Executes the installation stack for a server process. Bubbles any errors up to the calling // function which should handle contacting the panel to notify it of the server state. -func (s *Server) Install() error { +// +// Pass true as the first arugment in order to execute a server sync before the process to +// ensure the latest information is used. +func (s *Server) Install(sync bool) error { + if sync { + s.Log().Info("syncing server state with remote source before executing installation process") + if err := s.Sync(); err != nil { + return err + } + } + err := s.internalInstall() s.Log().Debug("notifying panel of server install state") @@ -55,7 +65,7 @@ func (s *Server) Reinstall() error { } } - return s.Install() + return s.Install(true) } // Internal installation function used to simplify reporting back to the Panel.