diff --git a/environment/docker/stream.go b/environment/docker/stream.go index 4cd447c..216018e 100644 --- a/environment/docker/stream.go +++ b/environment/docker/stream.go @@ -7,6 +7,7 @@ import ( "encoding/json" "github.com/docker/docker/api/types" "github.com/pkg/errors" + "github.com/pterodactyl/wings/environment" "strconv" ) @@ -30,6 +31,15 @@ func (e *Environment) SendCommand(c string) error { return errors.New("attempting to send command to non-attached instance") } + if e.meta.Stop != nil { + // If the command being processed is the same as the process stop command then we want to mark + // the server as entering the stopping state otherwise the process will stop and Wings will think + // it has crashed and attempt to restart it. + if e.meta.Stop.Type == "command" && c == e.meta.Stop.Value { + e.Events().Publish(environment.StateChangeEvent, environment.ProcessStoppingState) + } + } + _, err := e.stream.Conn.Write([]byte(c + "\n")) return errors.WithStack(err)