signals

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL