gracequit

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package gracequit handle delete pid file at dead, set logging path and folder, setup http/pprof service and etc. common tasks for background service.

Example:

ctx := gracequit.New(
	myPathPid,
	2,
).Init()

...

for {
		select {
		case <-ctx.Done():
			{
				return
			}
		case <-time.After(d):
			{
				// err := myOtherJob(...)
				gutil.CheckErr(err)
			}
		}
	}

Index

Constants

View Source
const (
	// DefaultQuitAfterSecs quit main process after n seconds
	DefaultQuitAfterSecs = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GraceQuit

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

GraceQuit internal struct holds settings

func New

func New(pathPid string, quitAfterSecs int) *GraceQuit

New initialize.

func (*GraceQuit) GetContext

func (it *GraceQuit) GetContext() context.Context

GetContext use context.Context share states.

func (*GraceQuit) Init

func (it *GraceQuit) Init() (ctx context.Context)

Jump to

Keyboard shortcuts

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