Skip to content

Commit

Permalink
minor edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Utkarsh Shukla committed Dec 19, 2024
1 parent 548bf51 commit 7872573
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions internal/serviceconfig/service_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,21 @@ func RunHTTPSServer(ctx context.Context, em EchoManager, routes Destinations, tl
}

func gracefulShutdown(server *http.Server, ctx context.Context){
// logger := logging.WithContext(ctx).Sugar()
logger := logging.WithContext(ctx).Sugar()
// logger.Infof("Received signal: %v. Initiating graceful shutdown...\n")

// Create a context with timeout for the shutdown process
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

// Shutdown the server gracefully
server.Shutdown(ctx)
// if err := server.Shutdown(ctx); err != nil {
// logger.Infof("Server shutdown failed: %v\n", err)
// } else {
// logger.Infof("Server shutdown completed successfully.")
// }
// server.Shutdown(ctx)
if err := server.Shutdown(ctx); err != nil {
// logger.Infof("Server shutdown failed: %v\n", err)
logger.Infof("Server handled")
} else {
logger.Infof("Server handled.")
}

// sigchan <- syscall.SIGTERM
os.Exit(0)
Expand Down

0 comments on commit 7872573

Please sign in to comment.