Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/template/framework/files/main/fiber_main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ import (

func gracefulShutdown(fiberServer *server.FiberServer, done chan bool) {
// Create context that listens for the interrupt signal from the OS.
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
sigCtx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()

// Listen for the interrupt signal.
<-ctx.Done()
<-sigCtx.Done()

log.Println("shutting down gracefully, press Ctrl+C again to force")
stop() // Allow Ctrl+C to force shutdown

// The context is used to inform the server it has 5 seconds to finish
// the request it is currently handling
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := fiberServer.ShutdownWithContext(ctx); err != nil {
if err := fiberServer.ShutdownWithContext(shutdownCtx); err != nil {
log.Printf("Server forced to shutdown with error: %v", err)
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/template/framework/files/main/main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ import (

func gracefulShutdown(apiServer *http.Server, done chan bool) {
// Create context that listens for the interrupt signal from the OS.
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
sigCtx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()

// Listen for the interrupt signal.
<-ctx.Done()
<-sigCtx.Done()

log.Println("shutting down gracefully, press Ctrl+C again to force")
stop() // Allow Ctrl+C to force shutdown

// The context is used to inform the server it has 5 seconds to finish
// the request it is currently handling
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := apiServer.Shutdown(ctx); err != nil {
if err := apiServer.Shutdown(shutdownCtx); err != nil {
log.Printf("Server forced to shutdown with error: %v", err)
}

Expand Down
Loading