add context timeouts to avoid hanging wings boot process if docker has a hiccup; closes pterodactyl/panel#3358

This commit is contained in:
Dane Everitt
2021-09-11 14:13:19 -07:00
parent 5cd43dd4c9
commit ee91224eb6
8 changed files with 64 additions and 44 deletions

View File

@@ -101,7 +101,7 @@ func postServerPower(c *gin.Context) {
func postServerCommands(c *gin.Context) {
s := ExtractServer(c)
if running, err := s.Environment.IsRunning(); err != nil {
if running, err := s.Environment.IsRunning(c.Request.Context()); err != nil {
NewServerError(err, s).Abort(c)
return
} else if !running {

View File

@@ -368,7 +368,9 @@ func (h *Handler) HandleInbound(m Message) error {
}
case SendServerLogsEvent:
{
if running, _ := h.server.Environment.IsRunning(); !running {
ctx, cancel := context.WithTimeout(context.Background(), time.Second * 5)
defer cancel()
if running, _ := h.server.Environment.IsRunning(ctx); !running {
return nil
}