Git Product home page Git Product logo

httpdown's Introduction

httpdown Build Status

Documentation: https://godoc.org/github.com/facebookgo/httpdown

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

If you want graceful restart and not just graceful shutdown, look at the grace package which uses this package underneath but also provides graceful restart.

Usage

Demo HTTP Server with graceful termination: https://github.com/facebookgo/httpdown/blob/master/httpdown_example/main.go

  1. Install the demo application

     go get github.com/facebookgo/httpdown/httpdown_example
    
  2. Start it in the first terminal

     httpdown_example
    

    This will output something like:

     2014/11/18 21:57:50 serving on http://127.0.0.1:8080/ with pid 17
    
  3. In a second terminal start a slow HTTP request

     curl 'http://localhost:8080/?duration=20s'
    
  4. In a third terminal trigger a graceful shutdown (using the pid from your output):

     kill -TERM 17
    

This will demonstrate that the slow request was served before the server was shutdown. You could also have used Ctrl-C instead of kill as the example application triggers graceful shutdown on TERM or INT signals.

httpdown's People

Contributors

daaku avatar jsha avatar titanous avatar

Watchers

James Cloos avatar 徐向阳 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.