From 1b91bc2e02c6a4db397df6a6a4ea6cb01944fe2d Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Fri, 10 Feb 2023 12:02:52 +0000 Subject: [PATCH] controller: add more informative server exit messages When exiting, we should ideally always print a message, and give details as to exactly what error we received. Signed-off-by: Justin Chadwell --- controller/remote/controller.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/controller/remote/controller.go b/controller/remote/controller.go index beb21abe..a13f27af 100644 --- a/controller/remote/controller.go +++ b/controller/remote/controller.go @@ -151,18 +151,21 @@ func serveCmd(dockerCli command.Cli) *cobra.Command { errCh <- errors.Wrapf(err, "error on serving via socket %q", addr) } }() + var s os.Signal sigCh := make(chan os.Signal, 1) signal.Notify(sigCh, os.Interrupt) select { - case s = <-sigCh: - logrus.Debugf("got signal %v", s) case err := <-errCh: + logrus.Errorf("got error %s, exiting", err) return err + case s = <-sigCh: + logrus.Infof("got signal %s, exiting", s) + return nil case <-doneCh: + logrus.Infof("rpc server done, exiting") + return nil } - return nil - }, }