diff --git a/config/config.go b/config/config.go index 0326f8e..508261c 100644 --- a/config/config.go +++ b/config/config.go @@ -82,7 +82,7 @@ type SystemConfiguration struct { Gid int } - // Determines wether or not server data should be synced when the Daemon is started. + // 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"` diff --git a/installer/installer.go b/installer/installer.go index 4ee7f32..d450baf 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) + s2, err := server.FromConfiguration(b, &config.Get().System, true) return &Installer{ server: s2, diff --git a/router/error.go b/router/error.go index ed84fe5..aa985d2 100644 --- a/router/error.go +++ b/router/error.go @@ -5,6 +5,7 @@ import ( "github.com/gin-gonic/gin" "github.com/google/uuid" "github.com/pkg/errors" + "github.com/pterodactyl/wings/config" "github.com/pterodactyl/wings/server" "go.uber.org/zap" "net/http" @@ -68,6 +69,12 @@ func (e *RequestError) AbortWithStatus(status int, c *gin.Context) { } c.Error(errors.WithStack(e)) + } else if config.Get().Debug { + if e.server != nil { + zap.S().Debugw("encountered error while handling HTTP request", zap.String("server", e.server.Uuid), zap.String("error_id", e.Uuid), zap.Error(e.Err)) + } else { + zap.S().Debugw("encountered error while handling HTTP request", zap.String("error_id", e.Uuid), zap.Error(e.Err)) + } } msg := "An unexpected error was encountered while processing this request." diff --git a/server/server.go b/server/server.go index 05eb264..b095b84 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) + s, err := FromConfiguration(b, cfg, false) 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) (*Server, error) { +func FromConfiguration(data []byte, cfg *config.SystemConfiguration, forceSync bool) (*Server, error) { s := new(Server) if err := defaults.Set(s); err != nil { @@ -244,7 +244,7 @@ func FromConfiguration(data []byte, cfg *config.SystemConfiguration) (*Server, e // 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 cfg.SyncServersOnBoot { + if forceSync || cfg.SyncServersOnBoot { if err := s.Sync(); err != nil { return nil, err } @@ -414,4 +414,4 @@ func (s *Server) HandlePowerAction(action PowerAction) error { default: return errors.New("an invalid power action was provided") } -} \ No newline at end of file +}