• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

httpdown_example/H23-Mar-2016-

.travis.ymlH A D23-Mar-2016485

httpdown.goH A D23-Mar-20169 KiB

httpdown_test.goH A D23-Mar-201617.4 KiB

licenseH A D23-Mar-20161.5 KiB

patentsH A D23-Mar-20161.9 KiB

readme.mdH A D23-Mar-20161.4 KiB

readme.md

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