Documentation
¶
Overview ¶
Example ¶
ExampleSetupSignalHandler demonstrates basic usage of the signal handler.
package main
import (
"fmt"
"time"
"github.com/grhili/cd-operator/pkg/signals"
)
func main() {
// Setup signal handler
ctx, cancel := signals.SetupSignalHandler()
defer cancel()
// Simulate application work
fmt.Println("application started")
// Use the context for graceful shutdown
select {
case <-ctx.Done():
fmt.Println("shutting down gracefully")
case <-time.After(100 * time.Millisecond):
fmt.Println("work completed")
}
}
Output: application started work completed
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetupSignalHandler ¶
func SetupSignalHandler() (context.Context, context.CancelFunc)
SetupSignalHandler creates a context that cancels on SIGTERM or SIGINT. It returns the context and a cancel function for cleanup. Kubernetes sends SIGTERM for graceful shutdown during pod termination.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.