closeevent

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: MIT Imports: 4 Imported by: 0

README

#closeevent

##demo

func demo(){ c := make(chan os.Signal) signalNotify(c) for { fmt.Println("run...")

	s := <-c

	//收到信号后的处理,这里只是输出信号内容,可以做一些更有意思的事
	fmt.Println("get signal:", s)
	fmt.Println("close...")
	
	//do your own close...
	//doCloseFunction()
		
	break
}

}

func demo(){
	//graceful shutdown
	var wg sync.WaitGroup
	//
	go func() {
		http.Server(host,nil)
	}()

	closeevent.Wait(func(sig os.Signal) {
		http.Shutdown()
		wg.Wait()
	})
}

Documentation

Overview

signal notify close event(win:INT,TREM)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseNotify

func CloseNotify(c chan os.Signal)

func Wait

func Wait(stopcall func(os.Signal), signals ...os.Signal)

Types

This section is empty.

Jump to

Keyboard shortcuts

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