Set server to stopping when stop command is sent

This commit is contained in:
Dane Everitt 2019-09-22 21:33:44 -07:00
parent 00bc71afd1
commit 4e1b7988bf
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -1,6 +1,7 @@
package server package server
import ( import (
"github.com/pterodactyl/wings/api"
"go.uber.org/zap" "go.uber.org/zap"
"strings" "strings"
) )
@ -28,6 +29,15 @@ func (s *Server) onConsoleOutput() *func(string) {
s.SetState(ProcessRunningState) s.SetState(ProcessRunningState)
} }
// If the command sent to the server is one that should stop the server we will need to
// set the server to be in a stopping state, otherwise crash detection will kick in and
// cause the server to unexpectedly restart on the user.
if s.State == ProcessStartingState || s.State == ProcessRunningState {
if s.processConfiguration.Stop.Type == api.ProcessStopCommand && data == s.processConfiguration.Stop.Value {
s.SetState(ProcessStoppingState)
}
}
} }
} }