From 891e5baa275acce56c8146b9cbcbef790c6c46c8 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Mon, 7 Sep 2020 15:53:44 -0700 Subject: [PATCH] Don't restart if the stop command is manually sent to the console --- environment/docker/stream.go | 10 ++++++++++ 1 file changed, 10 insertions(+) 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)