environment(docker): improve logging and stacks
This commit is contained in:
parent
e74d8e3501
commit
9b8b3c90fb
|
@ -58,7 +58,7 @@ func (e *Environment) Attach(ctx context.Context) error {
|
|||
|
||||
// Set the stream again with the container.
|
||||
if st, err := e.client.ContainerAttach(ctx, e.Id, opts); err != nil {
|
||||
return err
|
||||
return errors.WrapIf(err, "environment/docker: error while attaching to container")
|
||||
} else {
|
||||
e.SetStream(&st)
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ func (e *Environment) Create() error {
|
|||
if _, err := e.ContainerInspect(ctx); err == nil {
|
||||
return nil
|
||||
} else if !client.IsErrNotFound(err) {
|
||||
return errors.Wrap(err, "environment/docker: failed to inspect container")
|
||||
return errors.WrapIf(err, "environment/docker: failed to inspect container")
|
||||
}
|
||||
|
||||
// Try to pull the requested image before creating the container.
|
||||
|
|
|
@ -161,7 +161,7 @@ func (e *Environment) ExitState() (uint32, bool, error) {
|
|||
if client.IsErrNotFound(err) {
|
||||
return 1, false, nil
|
||||
}
|
||||
return 0, false, err
|
||||
return 0, false, errors.WrapIf(err, "environment/docker: failed to inspect container")
|
||||
}
|
||||
return uint32(c.State.ExitCode), c.State.OOMKilled, nil
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ func (e *Environment) Start(ctx context.Context) error {
|
|||
// exists on the system, and rebuild the container if that is required for server booting to
|
||||
// occur.
|
||||
if err := e.OnBeforeStart(ctx); err != nil {
|
||||
return errors.WithStackIf(err)
|
||||
return errors.WrapIf(err, "environment/docker: failed to run pre-boot process")
|
||||
}
|
||||
|
||||
// If we cannot start & attach to the container in 30 seconds something has gone
|
||||
|
@ -119,7 +119,7 @@ func (e *Environment) Start(ctx context.Context) error {
|
|||
// By explicitly attaching to the instance before we start it, we can immediately
|
||||
// react to errors/output stopping/etc. when starting.
|
||||
if err := e.Attach(actx); err != nil {
|
||||
return err
|
||||
return errors.WrapIf(err, "environment/docker: failed to attach to container")
|
||||
}
|
||||
|
||||
if err := e.client.ContainerStart(actx, e.Id, types.ContainerStartOptions{}); err != nil {
|
||||
|
|
|
@ -58,7 +58,7 @@ func getServerWebsocket(c *gin.Context) {
|
|||
case <-ctx.Done():
|
||||
break
|
||||
case <-s.Context().Done():
|
||||
handler.Connection.WriteControl(ws.CloseMessage, ws.FormatCloseMessage(ws.CloseGoingAway, "server deleted"), time.Now().Add(time.Second*5))
|
||||
_ = handler.Connection.WriteControl(ws.CloseMessage, ws.FormatCloseMessage(ws.CloseGoingAway, "server deleted"), time.Now().Add(time.Second*5))
|
||||
break
|
||||
}
|
||||
}()
|
||||
|
@ -83,7 +83,7 @@ func getServerWebsocket(c *gin.Context) {
|
|||
|
||||
go func(msg websocket.Message) {
|
||||
if err := handler.HandleInbound(ctx, msg); err != nil {
|
||||
handler.SendErrorJson(msg, err)
|
||||
_ = handler.SendErrorJson(msg, err)
|
||||
}
|
||||
}(j)
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"emperror.dev/errors"
|
||||
|
||||
"github.com/pterodactyl/wings/config"
|
||||
"github.com/pterodactyl/wings/environment"
|
||||
)
|
||||
|
@ -57,7 +59,7 @@ func (s *Server) handleServerCrash() error {
|
|||
|
||||
exitCode, oomKilled, err := s.Environment.ExitState()
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "failed to get exit state for server process")
|
||||
}
|
||||
|
||||
// If the system is not configured to detect a clean exit code as a crash, and the
|
||||
|
@ -85,5 +87,5 @@ func (s *Server) handleServerCrash() error {
|
|||
|
||||
s.crasher.SetLastCrash(time.Now())
|
||||
|
||||
return s.HandlePowerAction(PowerActionStart)
|
||||
return errors.Wrap(s.HandlePowerAction(PowerActionStart), "failed to start server after crash detection")
|
||||
}
|
||||
|
|
|
@ -147,6 +147,7 @@ func (s *Server) Context() context.Context {
|
|||
// server instance.
|
||||
func (s *Server) GetEnvironmentVariables() []string {
|
||||
out := []string{
|
||||
// TODO: allow this to be overridden by the user.
|
||||
fmt.Sprintf("TZ=%s", config.Get().System.Timezone),
|
||||
fmt.Sprintf("STARTUP=%s", s.Config().Invocation),
|
||||
fmt.Sprintf("SERVER_MEMORY=%d", s.MemoryLimit()),
|
||||
|
|
Loading…
Reference in New Issue
Block a user