Don't restart if the stop command is manually sent to the console

This commit is contained in:
Dane Everitt 2020-09-07 15:53:44 -07:00
parent 001bbfad1b
commit 891e5baa27
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -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)