Grace

Grace is graceful shutdown implementation for Go.

Installation

go get github.com/msrexe/grace

Example

func main() {
	go func() {
		grace.ShutdownWithTimeout(5*time.Second, func() {
			log.Println("Application gracefully stopped")
		})
	}()

	for {
		log.Println("Hello World")
		time.Sleep(2 * time.Second)
	}
}

For more examples, look at the example directory.

GitHub

View Github