From 7c82c6445dfdc165fd72a4cc74845a333304adc0 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 29 Jun 2019 17:52:55 -0700 Subject: [PATCH] Correctly connect to running containers --- server/environment_docker.go | 5 ++++- websocket.go | 3 --- wings.go | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/environment_docker.go b/server/environment_docker.go index 2e924d9..1bce5af 100644 --- a/server/environment_docker.go +++ b/server/environment_docker.go @@ -149,7 +149,6 @@ func (d *DockerEnvironment) Start() error { return err } - d.FollowConsoleOutput() return d.Attach() } @@ -188,6 +187,10 @@ func (d *DockerEnvironment) Attach() error { return nil } + if err := d.FollowConsoleOutput(); err != nil { + return err + } + ctx := context.Background() var err error diff --git a/websocket.go b/websocket.go index 325da64..4586755 100644 --- a/websocket.go +++ b/websocket.go @@ -78,9 +78,6 @@ func (rt *Router) routeWebsocket(w http.ResponseWriter, r *http.Request, ps http defer s.RemoveListener(server.ConsoleOutputEvent, &handleOutput) s.Emit(server.StatusEvent, s.State) - if s.State != server.ProcessOfflineState { - handler.HandleInbound(WebsocketMessage{inbound: true, Event: SendServerLogsEvent}) - } for { j := WebsocketMessage{inbound: true} diff --git a/wings.go b/wings.go index 7019598..9845914 100644 --- a/wings.go +++ b/wings.go @@ -74,6 +74,8 @@ func main() { zap.S().Infow("detected server is running, re-attaching to process", zap.String("server", s.Uuid)) if err := s.Environment.Attach(); err != nil { zap.S().Errorw("error attaching to server environment", zap.String("server", s.Uuid), zap.Error(err)) + } else { + s.SetState(server.ProcessRunningState) } } }