From 7e2f1734605e403f54d40e2de5b86a91b1e4fcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Thu, 2 Sep 2021 00:00:29 +0200 Subject: [PATCH] unify shutdown logs. --- internal/capture/broadcast.go | 2 +- internal/capture/manager.go | 2 +- internal/http/manager.go | 2 ++ internal/webrtc/manager.go | 2 +- internal/websocket/manager.go | 9 ++++----- neko.go | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/internal/capture/broadcast.go b/internal/capture/broadcast.go index ab9d9dfa..fb9615ca 100644 --- a/internal/capture/broadcast.go +++ b/internal/capture/broadcast.go @@ -30,7 +30,7 @@ func broadcastNew(pipelineStr string) *BroacastManagerCtx { } func (manager *BroacastManagerCtx) shutdown() { - manager.logger.Info().Msgf("shutting down") + manager.logger.Info().Msgf("shutdown") manager.destroyPipeline() } diff --git a/internal/capture/manager.go b/internal/capture/manager.go index b3e6a48a..690de43f 100644 --- a/internal/capture/manager.go +++ b/internal/capture/manager.go @@ -162,7 +162,7 @@ func (manager *CaptureManagerCtx) Start() { } func (manager *CaptureManagerCtx) Shutdown() error { - manager.logger.Info().Msgf("capture shutting down") + manager.logger.Info().Msgf("shutdown") manager.broadcast.shutdown() manager.screencast.shutdown() diff --git a/internal/http/manager.go b/internal/http/manager.go index 1a321213..51d3cd1d 100644 --- a/internal/http/manager.go +++ b/internal/http/manager.go @@ -94,5 +94,7 @@ func (manager *HttpManagerCtx) Start() { } func (manager *HttpManagerCtx) Shutdown() error { + manager.logger.Info().Msg("shutdown") + return manager.http.Shutdown(context.Background()) } diff --git a/internal/webrtc/manager.go b/internal/webrtc/manager.go index 00d241ce..d33cd212 100644 --- a/internal/webrtc/manager.go +++ b/internal/webrtc/manager.go @@ -92,7 +92,7 @@ func (manager *WebRTCManagerCtx) Start() { } func (manager *WebRTCManagerCtx) Shutdown() error { - manager.logger.Info().Msg("webrtc shutdown") + manager.logger.Info().Msg("shutdown") manager.curImage.Shutdown() manager.curPosition.Shutdown() diff --git a/internal/websocket/manager.go b/internal/websocket/manager.go index 421ab31f..9f15fd3d 100644 --- a/internal/websocket/manager.go +++ b/internal/websocket/manager.go @@ -131,7 +131,8 @@ func (manager *WebSocketManagerCtx) Start() { } func (manager *WebSocketManagerCtx) Shutdown() error { - manager.logger.Info().Msg("websocket shutdown") + manager.logger.Info().Msg("shutdown") + // TODO: Kill all connections and add waitgroup for gorutines. return nil } @@ -178,10 +179,8 @@ func (manager *WebSocketManagerCtx) Upgrade(w http.ResponseWriter, r *http.Reque manager.logger.Err(err).Msg("failed to send disconnect event") } - if err := connection.Close(); err != nil { - manager.logger.Warn().Err(err).Msg("connection closed with an error") - } - + err = connection.Close() + manager.logger.Err(err).Msg("connection closed") return } diff --git a/neko.go b/neko.go index 4328ba04..af1ce98b 100644 --- a/neko.go +++ b/neko.go @@ -228,7 +228,7 @@ func (neko *Neko) ServeCommand(cmd *cobra.Command, args []string) { signal.Notify(quit, os.Interrupt) sig := <-quit - neko.logger.Warn().Msgf("received %s, attempting graceful shutdown: \n", sig) + neko.logger.Warn().Msgf("received %s, attempting graceful shutdown", sig) neko.Shutdown() neko.logger.Info().Msg("shutdown complete") }