Switch old Server#GetState() calls over to Server#Environment#State()
This commit is contained in:
parent
287b286940
commit
73b221d022
|
@ -311,7 +311,7 @@ func (h *Handler) HandleInbound(m Message) error {
|
||||||
|
|
||||||
// On every authentication event, send the current server status back
|
// On every authentication event, send the current server status back
|
||||||
// to the client. :)
|
// to the client. :)
|
||||||
state := h.server.GetState()
|
state := h.server.Environment.State()
|
||||||
h.SendJson(&Message{
|
h.SendJson(&Message{
|
||||||
Event: server.StatusEvent,
|
Event: server.StatusEvent,
|
||||||
Args: []string{state},
|
Args: []string{state},
|
||||||
|
@ -398,7 +398,7 @@ func (h *Handler) HandleInbound(m Message) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if h.server.GetState() == environment.ProcessOfflineState {
|
if h.server.Environment.State() == environment.ProcessOfflineState {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ func (h *Handler) HandleInbound(m Message) error {
|
||||||
// so that we can better handle this and only set the environment to booted once we're attached.
|
// so that we can better handle this and only set the environment to booted once we're attached.
|
||||||
//
|
//
|
||||||
// Or maybe just an IsBooted function?
|
// Or maybe just an IsBooted function?
|
||||||
if h.server.GetState() == environment.ProcessStartingState {
|
if h.server.Environment.State() == environment.ProcessStartingState {
|
||||||
if e, ok := h.server.Environment.(*docker.Environment); ok {
|
if e, ok := h.server.Environment.(*docker.Environment); ok {
|
||||||
if !e.IsAttached() {
|
if !e.IsAttached() {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -45,7 +45,7 @@ func (s *Server) handleServerCrash() error {
|
||||||
// No point in doing anything here if the server isn't currently offline, there
|
// No point in doing anything here if the server isn't currently offline, there
|
||||||
// is no reason to do a crash detection event. If the server crash detection is
|
// is no reason to do a crash detection event. If the server crash detection is
|
||||||
// disabled we want to skip anything after this as well.
|
// disabled we want to skip anything after this as well.
|
||||||
if s.GetState() != environment.ProcessOfflineState || !s.Config().CrashDetectionEnabled {
|
if s.Environment.State() != environment.ProcessOfflineState || !s.Config().CrashDetectionEnabled {
|
||||||
if !s.Config().CrashDetectionEnabled {
|
if !s.Config().CrashDetectionEnabled {
|
||||||
s.Log().Debug("server triggered crash detection but handler is disabled for server process")
|
s.Log().Debug("server triggered crash detection but handler is disabled for server process")
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ func (s *Server) Install(sync bool) error {
|
||||||
// Reinstalls a server's software by utilizing the install script for the server egg. This
|
// Reinstalls a server's software by utilizing the install script for the server egg. This
|
||||||
// does not touch any existing files for the server, other than what the script modifies.
|
// does not touch any existing files for the server, other than what the script modifies.
|
||||||
func (s *Server) Reinstall() error {
|
func (s *Server) Reinstall() error {
|
||||||
if s.GetState() != environment.ProcessOfflineState {
|
if s.Environment.State() != environment.ProcessOfflineState {
|
||||||
s.Log().Debug("waiting for server instance to enter a stopped state")
|
s.Log().Debug("waiting for server instance to enter a stopped state")
|
||||||
if err := s.Environment.WaitForStop(10, true); err != nil {
|
if err := s.Environment.WaitForStop(10, true); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -152,7 +152,7 @@ func (s *Server) onConsoleOutput(data string) {
|
||||||
processConfiguration := s.ProcessConfiguration()
|
processConfiguration := s.ProcessConfiguration()
|
||||||
|
|
||||||
// Check if the server is currently starting.
|
// Check if the server is currently starting.
|
||||||
if s.GetState() == environment.ProcessStartingState {
|
if s.Environment.State() == environment.ProcessStartingState {
|
||||||
// Check if we should strip ansi color codes.
|
// Check if we should strip ansi color codes.
|
||||||
if processConfiguration.Startup.StripAnsi {
|
if processConfiguration.Startup.StripAnsi {
|
||||||
// Strip ansi color codes from the data string.
|
// Strip ansi color codes from the data string.
|
||||||
|
|
|
@ -104,7 +104,7 @@ func (s *Server) HandlePowerAction(action PowerAction, waitSeconds ...int) error
|
||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
case PowerActionStart:
|
case PowerActionStart:
|
||||||
if s.GetState() != environment.ProcessOfflineState {
|
if s.Environment.State() != environment.ProcessOfflineState {
|
||||||
return ErrIsRunning
|
return ErrIsRunning
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ func saveServerStates() error {
|
||||||
// Get the states of all servers on the daemon.
|
// Get the states of all servers on the daemon.
|
||||||
states := map[string]string{}
|
states := map[string]string{}
|
||||||
for _, s := range GetServers().All() {
|
for _, s := range GetServers().All() {
|
||||||
states[s.Id()] = s.GetState()
|
states[s.Id()] = s.Environment.State()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the map to a json object.
|
// Convert the map to a json object.
|
||||||
|
@ -107,7 +107,7 @@ func (s *Server) OnStateChange() {
|
||||||
// automatically attempt to start the process back up for the user. This is done in a
|
// automatically attempt to start the process back up for the user. This is done in a
|
||||||
// separate thread as to not block any actions currently taking place in the flow
|
// separate thread as to not block any actions currently taking place in the flow
|
||||||
// that called this function.
|
// that called this function.
|
||||||
if (prevState == environment.ProcessStartingState || prevState == environment.ProcessRunningState) && s.GetState() == environment.ProcessOfflineState {
|
if (prevState == environment.ProcessStartingState || prevState == environment.ProcessRunningState) && s.Environment.State() == environment.ProcessOfflineState {
|
||||||
s.Log().Info("detected server as entering a crashed state; running crash handler")
|
s.Log().Info("detected server as entering a crashed state; running crash handler")
|
||||||
|
|
||||||
go func(server *Server) {
|
go func(server *Server) {
|
||||||
|
@ -133,7 +133,7 @@ func (s *Server) GetState() string {
|
||||||
// environment state, it is simply the tracked state from this daemon instance, and
|
// environment state, it is simply the tracked state from this daemon instance, and
|
||||||
// not the response from Docker.
|
// not the response from Docker.
|
||||||
func (s *Server) IsRunning() bool {
|
func (s *Server) IsRunning() bool {
|
||||||
st := s.GetState()
|
st := s.Environment.State()
|
||||||
|
|
||||||
return st == environment.ProcessRunningState || st == environment.ProcessStartingState
|
return st == environment.ProcessRunningState || st == environment.ProcessStartingState
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ func (s *Server) SyncWithEnvironment() {
|
||||||
} else {
|
} else {
|
||||||
// Checks if the server is now in a suspended state. If so and a server process is currently running it
|
// Checks if the server is now in a suspended state. If so and a server process is currently running it
|
||||||
// will be gracefully stopped (and terminated if it refuses to stop).
|
// will be gracefully stopped (and terminated if it refuses to stop).
|
||||||
if s.GetState() != environment.ProcessOfflineState {
|
if s.Environment.State() != environment.ProcessOfflineState {
|
||||||
s.Log().Info("server suspended with running process state, terminating now")
|
s.Log().Info("server suspended with running process state, terminating now")
|
||||||
|
|
||||||
go func(s *Server) {
|
go func(s *Server) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user