lingdor / gexit

graceful,safty exit your golang program.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gexit (graceful exit)

graceful,safty exit for your golang program.

demo

/

go get github.com/lingdor/gexit

init module code :

ctx:=context.Background()
gexit.InitGExit(ctx)

exit func callback

gexit.AddPreExitFunc(func(){
	fmt.Println("pre exit invoked!")
})

Context run

ctx:=gexit.GetContext()  //get exit context
for{
    select{
        case <-ctx.Done(): //when exit event
            fmt.Printf("goroutine %d at done!\n",num)
            return
        default:break
    }
    //normal program
}

gexit-example

https://github.com/lingdor/gexit-example

#contact

mailto: bobby96333@gmail.com

About

graceful,safty exit your golang program.

License:Apache License 2.0


Languages

Language:Go 100.0%