From e719c67e0b82ece53e81894a86d96143c7966fa3 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Fri, 10 Apr 2020 12:15:46 -0600 Subject: [PATCH] Removes SyncServersOnBoot configuration option and requires that servers are synced when the daemon boots --- config/config.go | 5 ----- installer/installer.go | 2 +- server/server.go | 14 +++++--------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/config/config.go b/config/config.go index 508261c..3b5f47c 100644 --- a/config/config.go +++ b/config/config.go @@ -82,11 +82,6 @@ type SystemConfiguration struct { Gid int } - // Determines whether or not server data should be synced when the Daemon is started. - // If set to false, data will only be synced when a server process is started, or - // detected as started when booting. - SyncServersOnBoot bool `default:"true" yaml:"sync_servers_on_boot"` - // The path to the system's timezone file that will be mounted into running Docker containers. TimezonePath string `yaml:"timezone_path"` diff --git a/installer/installer.go b/installer/installer.go index d450baf..4ee7f32 100644 --- a/installer/installer.go +++ b/installer/installer.go @@ -84,7 +84,7 @@ func New(data []byte) (*Installer, error) { // Create a new server instance using the configuration we wrote to the disk // so that everything gets instantiated correctly on the struct. - s2, err := server.FromConfiguration(b, &config.Get().System, true) + s2, err := server.FromConfiguration(b, &config.Get().System) return &Installer{ server: s2, diff --git a/server/server.go b/server/server.go index b095b84..9b66559 100644 --- a/server/server.go +++ b/server/server.go @@ -179,7 +179,7 @@ func LoadDirectory(dir string, cfg *config.SystemConfiguration) error { return } - s, err := FromConfiguration(b, cfg, false) + s, err := FromConfiguration(b, cfg) if err != nil { if IsServerDoesNotExistError(err) { zap.S().Infow("server does not exist on remote system", zap.String("server", file.Name())) @@ -209,7 +209,7 @@ func (s *Server) Init() { // Initializes a server using a data byte array. This will be marshaled into the // given struct using a YAML marshaler. This will also configure the given environment // for a server. -func FromConfiguration(data []byte, cfg *config.SystemConfiguration, forceSync bool) (*Server, error) { +func FromConfiguration(data []byte, cfg *config.SystemConfiguration) (*Server, error) { s := new(Server) if err := defaults.Set(s); err != nil { @@ -241,13 +241,9 @@ func FromConfiguration(data []byte, cfg *config.SystemConfiguration, forceSync b } s.Resources = ResourceUsage{} - // This is also done when the server is booted, however we need to account for instances - // where the server is already running and the Daemon reboots. In those cases this will - // allow us to you know, stop servers. - if forceSync || cfg.SyncServersOnBoot { - if err := s.Sync(); err != nil { - return nil, err - } + // Forces the configuration to be synced with the panel. + if err := s.Sync(); err != nil { + return nil, err } return s, nil