Improve startup/shutdown logging
This commit is contained in:
parent
e93d2d2c8b
commit
5ec1d11ea7
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user