shutdown

package
v1.67.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 3 Imported by: 1

README

Package shutdown

Пакет shutdown предназначен для перехвата системных сигналов завершения (SIGINT, SIGTERM) и выполнения заданной пользователем функции при их получении.

Functions

func On(do func()) chan os.Signal

Запускает обработку сигналов завершения процесса (SIGINT, SIGTERM) и вызывает переданную функцию do при получении одного из этих сигналов.

Usage

package main

import (
	"fmt"
	"time"

	"github.com/txix-open/isp-kit/shutdown"
)

func main() {
	shutdown.On(func() {
		fmt.Println("shutting down...")
	})

	fmt.Println("working...")
	time.Sleep(30 * time.Second)
}

Documentation

Overview

Package shutdown provides utilities for handling process termination signals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func On

func On(do func()) chan os.Signal

On registers a callback function to be executed when the process receives SIGINT or SIGTERM signals. It returns a channel that receives the signal when it occurs. The callback runs in a separate goroutine upon signal receipt.

Example usage:

shutdown.On(func() {
    log.Println("Shutting down...")
})

Types

This section is empty.

Jump to

Keyboard shortcuts

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