You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.4 KiB

  1. httpdown [![Build Status](https://secure.travis-ci.org/facebookgo/httpdown.png)](https://travis-ci.org/facebookgo/httpdown)
  2. ========
  3. Documentation: https://godoc.org/github.com/facebookgo/httpdown
  4. Package httpdown provides a library that makes it easy to build a HTTP server
  5. that can be shutdown gracefully (that is, without dropping any connections).
  6. If you want graceful restart and not just graceful shutdown, look at the
  7. [grace](https://github.com/facebookgo/grace) package which uses this package
  8. underneath but also provides graceful restart.
  9. Usage
  10. -----
  11. Demo HTTP Server with graceful termination:
  12. https://github.com/facebookgo/httpdown/blob/master/httpdown_example/main.go
  13. 1. Install the demo application
  14. go get github.com/facebookgo/httpdown/httpdown_example
  15. 1. Start it in the first terminal
  16. httpdown_example
  17. This will output something like:
  18. 2014/11/18 21:57:50 serving on http://127.0.0.1:8080/ with pid 17
  19. 1. In a second terminal start a slow HTTP request
  20. curl 'http://localhost:8080/?duration=20s'
  21. 1. In a third terminal trigger a graceful shutdown (using the pid from your output):
  22. kill -TERM 17
  23. This will demonstrate that the slow request was served before the server was
  24. shutdown. You could also have used `Ctrl-C` instead of `kill` as the example
  25. application triggers graceful shutdown on TERM or INT signals.