unify shutdown logs.

This commit is contained in:
Miroslav Šedivý 2021-09-02 00:00:29 +02:00
parent fd35254487
commit 7e2f173460
6 changed files with 10 additions and 9 deletions

View File

@ -30,7 +30,7 @@ func broadcastNew(pipelineStr string) *BroacastManagerCtx {
} }
func (manager *BroacastManagerCtx) shutdown() { func (manager *BroacastManagerCtx) shutdown() {
manager.logger.Info().Msgf("shutting down") manager.logger.Info().Msgf("shutdown")
manager.destroyPipeline() manager.destroyPipeline()
} }

View File

@ -162,7 +162,7 @@ func (manager *CaptureManagerCtx) Start() {
} }
func (manager *CaptureManagerCtx) Shutdown() error { func (manager *CaptureManagerCtx) Shutdown() error {
manager.logger.Info().Msgf("capture shutting down") manager.logger.Info().Msgf("shutdown")
manager.broadcast.shutdown() manager.broadcast.shutdown()
manager.screencast.shutdown() manager.screencast.shutdown()

View File

@ -94,5 +94,7 @@ func (manager *HttpManagerCtx) Start() {
} }
func (manager *HttpManagerCtx) Shutdown() error { func (manager *HttpManagerCtx) Shutdown() error {
manager.logger.Info().Msg("shutdown")
return manager.http.Shutdown(context.Background()) return manager.http.Shutdown(context.Background())
} }

View File

@ -92,7 +92,7 @@ func (manager *WebRTCManagerCtx) Start() {
} }
func (manager *WebRTCManagerCtx) Shutdown() error { func (manager *WebRTCManagerCtx) Shutdown() error {
manager.logger.Info().Msg("webrtc shutdown") manager.logger.Info().Msg("shutdown")
manager.curImage.Shutdown() manager.curImage.Shutdown()
manager.curPosition.Shutdown() manager.curPosition.Shutdown()

View File

@ -131,7 +131,8 @@ func (manager *WebSocketManagerCtx) Start() {
} }
func (manager *WebSocketManagerCtx) Shutdown() error { 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 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") manager.logger.Err(err).Msg("failed to send disconnect event")
} }
if err := connection.Close(); err != nil { err = connection.Close()
manager.logger.Warn().Err(err).Msg("connection closed with an error") manager.logger.Err(err).Msg("connection closed")
}
return return
} }

View File

@ -228,7 +228,7 @@ func (neko *Neko) ServeCommand(cmd *cobra.Command, args []string) {
signal.Notify(quit, os.Interrupt) signal.Notify(quit, os.Interrupt)
sig := <-quit 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.Shutdown()
neko.logger.Info().Msg("shutdown complete") neko.logger.Info().Msg("shutdown complete")
} }