osUtil

package
v0.0.0-...-e50112c Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

README

操作系统信号的封装

  • 可以在进程退出前得到事件通知,允许应用程序在进程退出前执行自定义逻辑。
  • 如果系统中申请了某些重要资源、且这些资源不会因为进程退出而被操作系统自动回收,那么应当在进程退出前释放这些资源,以免进程重启之后新的进程会因为资源不足而无法启动。
  • 典型的比如分布式锁,在进程退出时就必须手动释放所有已经获得的锁。否则该锁就会长时间无法被其他模块获得。

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoLogOnSignalExit bool
)

Functions

func GetSignal

func GetSignal() syscall.Signal

获取已经收到的退出信号。 如果尚未收到退出信号,则返回 0

func OnSignalExit

func OnSignalExit(f func(sig syscall.Signal) (ok bool), msg ...string)

当收到操作系统的退出信号时触发。 信号包括:SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGKILL, SIGTERM

func OnSignalExitNoLog

func OnSignalExitNoLog(f func(sig syscall.Signal), msg ...string)

当收到操作系统的退出信号时触发。 信号包括:SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGKILL, SIGTERM

func TearDown

func TearDown(f func())

Types

This section is empty.

Jump to

Keyboard shortcuts

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