Fix logic for context based environment stopping
Uses dual contexts to handle stopping using a timed context, and also terminating the entire process loop if the parent context gets canceled.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/pterodactyl/wings/environment/docker"
|
||||
|
||||
"github.com/pterodactyl/wings/environment"
|
||||
@@ -58,7 +60,7 @@ func (s *Server) SyncWithEnvironment() {
|
||||
s.Log().Info("server suspended with running process state, terminating now")
|
||||
|
||||
go func(s *Server) {
|
||||
if err := s.Environment.WaitForStop(60, true); err != nil {
|
||||
if err := s.Environment.WaitForStop(s.Context(), time.Minute, true); err != nil {
|
||||
s.Log().WithField("error", err).Warn("failed to terminate server environment after suspension")
|
||||
}
|
||||
}(s)
|
||||
|
||||
Reference in New Issue
Block a user