Skip to content

Commit

Permalink
track shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
mredolatti authored and Israphel committed Aug 1, 2023
1 parent fa204db commit 5ce4512
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion splitio/common/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package common

import (
"errors"
"fmt"
"os"
"os/signal"
"runtime/debug"
"syscall"
"time"

Expand Down Expand Up @@ -79,6 +81,8 @@ func (r *RuntimeImpl) RegisterShutdownHandler() error {
signal.Notify(r.osSignals, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
s := <-r.osSignals

r.logger.Info(fmt.Sprintf("received signal %+v", s))
if s == syscall.SIGKILL {
os.Exit(0)
}
Expand All @@ -97,6 +101,7 @@ func (r *RuntimeImpl) Uptime() time.Duration {
func (r *RuntimeImpl) Shutdown() {
r.logger.Info("\n\n * Starting graceful shutdown")
r.logger.Info(" * Waiting goroutines stop")
r.logger.Debug("%s", string(debug.Stack()))
if r.slackWriter != nil {
message, attachments := buildSlackShutdownMessage(r.dashboardTitle, false)
r.slackWriter.PostNow(message, attachments)
Expand Down Expand Up @@ -137,7 +142,7 @@ func buildSlackShutdownMessage(title string, kill bool) ([]byte, []log.SlackMess
if title != "" {
fields := make([]log.SlackMessageAttachmentFields, 0)
fields = append(fields)
attach = []log.SlackMessageAttachment{log.SlackMessageAttachment{
attach = []log.SlackMessageAttachment{{
Fallback: "Shutting Split-Sync down",
Color: color,
Fields: []log.SlackMessageAttachmentFields{{
Expand Down

0 comments on commit 5ce4512

Please sign in to comment.