diff --git a/cmd/apiary.go b/cmd/apiary.go index 13db81f..bedc9ea 100644 --- a/cmd/apiary.go +++ b/cmd/apiary.go @@ -3,10 +3,12 @@ package main import ( "context" "fmt" + "net/http" "os" "os/signal" "time" + "github.com/gliderlabs/ssh" "github.com/urfave/cli/v2" "github.uio.no/torjus/apiary" "github.uio.no/torjus/apiary/config" @@ -86,18 +88,24 @@ func ActionServe(c *cli.Context) error { // Handle interrupt go func() { <-interruptChan - fmt.Println("Got interrupt. Shutting down.") + loggers.rootLogger.Info("Interrupt received, shutting down") serversCancel() }() // Start ssh server go func() { - hs.ListenAndServe() + loggers.rootLogger.Info("Starting SSH server") + if err := hs.ListenAndServe(); err != nil && err != ssh.ErrServerClosed { + loggers.rootLogger.Warnw("SSH server returned error", "error", err) + } }() // Start web server go func() { - web.ListenAndServe() + loggers.rootLogger.Info("Starting web server") + if err := web.ListenAndServe(); err != nil && err != http.ErrServerClosed { + loggers.rootLogger.Warnw("Web server returned error", "error", err) + } }() go func() {