Merge pull request #20 from matthewpi/issues/1899
Improved server loading
This commit is contained in:
@@ -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."
|
||||
|
||||
@@ -20,7 +20,7 @@ func getServerWebsocket(c *gin.Context) {
|
||||
defer handler.Connection.Close()
|
||||
|
||||
// Create a context that can be canceled when the user disconnects from this
|
||||
// socket that will also cancel listeners running in seperate threads.
|
||||
// socket that will also cancel listeners running in separate threads.
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
|
||||
@@ -211,6 +211,13 @@ func (h *Handler) HandleInbound(m Message) error {
|
||||
{
|
||||
token, err := NewTokenPayload([]byte(strings.Join(m.Args, "")))
|
||||
if err != nil {
|
||||
// If the error says the JWT expired, send a token expired
|
||||
// event and hopefully the client renews the token.
|
||||
if err == jwt.ErrExpValidation {
|
||||
h.SendJson(&Message{Event: TokenExpiredEvent})
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user