lifecycle

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists added in v1.3.5

func Exists(pidfile string) error

Exists open a pid file.

func GeneratePIDFile added in v1.3.5

func GeneratePIDFile(pidfile string) error

GeneratePIDFile create a pid file for own process.

func Open added in v1.3.5

func Open(pidfile string) (*os.Process, error)

Open open a pid file and return this process.

func OwnerID added in v0.4.19

func OwnerID() string

OwnerID 获取当前服务的ownerID

func Retry

func Retry(interval time.Duration, retryTimes int, fn func() (needRetry bool, err error)) (err error)

Retry 重試

Types

type LifeCycle

type LifeCycle struct {
	// contains filtered or unexported fields
}

LifeCycle 应用程序生命周期

func New

func New() *LifeCycle

New .

func Std

func Std() *LifeCycle

Std ..

func (*LifeCycle) AddCloseFunc

func (l *LifeCycle) AddCloseFunc(f func() error)

AddCloseFunc 添加退出任务

func (*LifeCycle) AddCloser

func (l *LifeCycle) AddCloser(clr io.Closer)

AddCloser 添加退出任务

func (*LifeCycle) C

func (l *LifeCycle) C() <-chan struct{}

C .

func (*LifeCycle) CancelContext added in v1.1.7

func (l *LifeCycle) CancelContext()

CancelContext 预退出

func (*LifeCycle) Context added in v0.1.22

func (l *LifeCycle) Context() context.Context

Context 上下文

func (*LifeCycle) Exit

func (l *LifeCycle) Exit()

Exit 强制退出

func (*LifeCycle) SetSignals

func (l *LifeCycle) SetSignals(sigs ...os.Signal)

SetSignals 设置监听的信号量

func (*LifeCycle) SetTimeout

func (l *LifeCycle) SetTimeout(d time.Duration)

SetTimeout 退出超时时间

func (*LifeCycle) WaitExit

func (l *LifeCycle) WaitExit()

WaitExit .

Jump to

Keyboard shortcuts

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