Improve server state logical handling; allow setting state directly on the environment

This commit is contained in:
Dane Everitt
2020-11-06 21:53:00 -08:00
parent 3fce1b98d5
commit 944d381778
13 changed files with 73 additions and 105 deletions

View File

@@ -60,7 +60,7 @@ func (e *Environment) Attach() error {
defer cancel()
defer e.stream.Close()
defer func() {
e.setState(environment.ProcessOfflineState)
e.SetState(environment.ProcessOfflineState)
e.SetStream(nil)
}()
@@ -245,7 +245,7 @@ func (e *Environment) convertMounts() []mount.Mount {
// it will be forcibly stopped by Docker.
func (e *Environment) Destroy() error {
// We set it to stopping than offline to prevent crash detection from being triggered.
e.setState(environment.ProcessStoppingState)
e.SetState(environment.ProcessStoppingState)
err := e.client.ContainerRemove(context.Background(), e.Id, types.ContainerRemoveOptions{
RemoveVolumes: true,
@@ -261,7 +261,7 @@ func (e *Environment) Destroy() error {
return nil
}
e.setState(environment.ProcessOfflineState)
e.SetState(environment.ProcessOfflineState)
return err
}