No description, website, or topics provided.
Latest commit c030b24 Jan 22, 2017 @shogo82148 committed on GitHub Merge pull request #2 from shogo82148/go1.8-shutdown
Go 1.8 support


Package go-gracedown provides a library that makes it easy to build a HTTP server that can be shutdown gracefully (that is, without dropping any connections).


import (


func main() {
  go func() {
    for {
      s := <-signal_chan
        if s == syscall.SIGTERM {
          gracedown.Close() // trigger graceful shutdown

  handler := MyHTTPHandler()
  gracedown.ListenAndServe(":7000", handler)

built-in graceful shutdown support (from Go version 1.8 onward)

From Go version 1.8 onward, the HTTP Server has support for graceful shutdown. (HTTP Server Graceful Shutdown) The go-gracedown package is just a wrapper of the net/http package to maintain interface compatibility. So you should use the "net/http".Server.Shutdown method and "net/http".Server.Close method directly.


  • Go version 1.7 or less: The grace.Server.Close method keeps currently-open connections.
  • From Go version 1.8 onward: The grace.Server.Close method drops currently-open connections.


See godoc for more information.