Skip to content

Commit 7cffc29

Browse files
DugowitchMichaelMraka
authored andcommitted
RHINENG-21760: add additional debug logs before shutdown
1 parent a3d7388 commit 7cffc29

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

base/base.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func HandleSignals() {
2626
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
2727
go func() {
2828
<-c
29+
utils.LogInfo("SIGTERM/SIGINT received")
2930
CancelContext()
3031
utils.LogInfo("SIGTERM/SIGINT handled")
3132
}()

base/utils/gin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func RunServer(ctx context.Context, handler http.Handler, port int) error {
108108
srv := http.Server{Addr: addr, Handler: handler, ReadHeaderTimeout: ReadHeaderTimeout, MaxHeaderBytes: 65535}
109109
go func() {
110110
<-ctx.Done()
111+
LogDebug("gracefully shutting down server...")
111112
err := srv.Shutdown(context.Background())
112113
if err != nil {
113114
LogError("err", err.Error(), "server shutting down failed")

base/utils/gin_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package utils
22

33
import (
44
"context"
5+
"testing"
6+
"time"
7+
58
"github.com/gin-gonic/gin"
69
log "github.com/sirupsen/logrus"
710
"github.com/stretchr/testify/assert"
8-
"testing"
9-
"time"
1011
)
1112

1213
func TestRunServer(t *testing.T) {
@@ -24,7 +25,8 @@ func TestRunServer(t *testing.T) {
2425
err := RunServer(ctx, gin.Default(), 8888)
2526
assert.Nil(t, err)
2627
AssertEqualWait(t, 1, func() (exp, act interface{}) {
27-
return 1, len(hook.LogEntries)
28+
return 2, len(hook.LogEntries)
2829
})
29-
assert.Equal(t, "server closed successfully", hook.LogEntries[0].Message)
30+
assert.Equal(t, "gracefully shutting down server...", hook.LogEntries[0].Message)
31+
assert.Equal(t, "server closed successfully", hook.LogEntries[1].Message)
3032
}

0 commit comments

Comments
 (0)