Merge branch 'dane/backup-restore' into develop
This commit is contained in:
@@ -2,6 +2,11 @@ package docker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"emperror.dev/errors"
|
||||
"github.com/apex/log"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/client"
|
||||
@@ -9,8 +14,6 @@ import (
|
||||
"github.com/pterodactyl/wings/environment"
|
||||
"github.com/pterodactyl/wings/events"
|
||||
"github.com/pterodactyl/wings/system"
|
||||
"io"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Metadata struct {
|
||||
@@ -187,3 +190,26 @@ func (e *Environment) SetImage(i string) {
|
||||
|
||||
e.meta.Image = i
|
||||
}
|
||||
|
||||
func (e *Environment) State() string {
|
||||
return e.st.Load()
|
||||
}
|
||||
|
||||
// SetState sets the state of the environment. This emits an event that server's
|
||||
// can hook into to take their own actions and track their own state based on
|
||||
// the environment.
|
||||
func (e *Environment) SetState(state string) {
|
||||
if state != environment.ProcessOfflineState &&
|
||||
state != environment.ProcessStartingState &&
|
||||
state != environment.ProcessRunningState &&
|
||||
state != environment.ProcessStoppingState {
|
||||
panic(errors.New(fmt.Sprintf("invalid server state received: %s", state)))
|
||||
}
|
||||
|
||||
// Emit the event to any listeners that are currently registered.
|
||||
if e.State() != state {
|
||||
// If the state changed make sure we update the internal tracking to note that.
|
||||
e.st.Store(state)
|
||||
e.Events().Publish(environment.StateChangeEvent, state)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"emperror.dev/errors"
|
||||
"fmt"
|
||||
"github.com/pterodactyl/wings/environment"
|
||||
)
|
||||
|
||||
func (e *Environment) State() string {
|
||||
return e.st.Load()
|
||||
}
|
||||
|
||||
// Sets the state of the environment. This emits an event that server's can hook into to
|
||||
// take their own actions and track their own state based on the environment.
|
||||
func (e *Environment) SetState(state string) {
|
||||
if state != environment.ProcessOfflineState &&
|
||||
state != environment.ProcessStartingState &&
|
||||
state != environment.ProcessRunningState &&
|
||||
state != environment.ProcessStoppingState {
|
||||
panic(errors.New(fmt.Sprintf("invalid server state received: %s", state)))
|
||||
}
|
||||
|
||||
// Emit the event to any listeners that are currently registered.
|
||||
if e.State() != state {
|
||||
// If the state changed make sure we update the internal tracking to note that.
|
||||
e.st.Store(state)
|
||||
e.Events().Publish(environment.StateChangeEvent, state)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user