0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 04:10:24 +00:00
Small, fast, modern HTTP server for Erlang/OTP.
Find a file
Viktor Söderqvist 059d58d39f
Graceful shutdown
Note: This commit makes cowboy depend on cowlib master.

Graceful shutdown for HTTP/2:

1. A GOAWAY frame with the last stream id set to 2^31-1 is sent and a
   timer is started (goaway_initial_timeout, default 1000ms), to wait
   for any in-flight requests sent by the client, and the status is set
   to 'closing_initiated'. If the client responds with GOAWAY and closes
   the connection, we're done.
2. A second GOAWAY frame is sent with the actual last stream id and the
   status is set to 'closing'. If no streams exist, the connection
   terminates. Otherwise a second timer (goaway_complete_timeout,
   default 3000ms) is started, to wait for the streams to complete. New
   streams are not accepted when status is 'closing'.
3. If all streams haven't completed after the second timeout, the
   connection is forcefully terminated.

Graceful shutdown for HTTP/1.x:

1. If a request is currently being handled, it is waited for and the
   response is sent back to the client with the header "Connection:
   close". Then, the connection is closed.
2. If the current request handler is not finished within the time
   configured in transport option 'shutdown' (default 5000ms), the
   connection process is killed by its supervisor (ranch).

Implemented for HTTP/1.x and HTTP/2 in the following scenarios:

* When receiving exit signal 'shutdown' from the supervisor (e.g. when
  cowboy:stop_listener/3 is called).
* When a connection process is requested to terminate using
  sys:terminate/2,3.

LH: Edited tests a bit and added todos for useful tests to add.
2020-11-27 15:38:21 +01:00
doc/src Graceful shutdown 2020-11-27 15:38:21 +01:00
ebin Cowboy 2.8.0 2020-05-21 19:02:12 +02:00
examples Remove jQuery, cleanup Websocket example a bit 2020-05-23 11:00:17 +02:00
src Graceful shutdown 2020-11-27 15:38:21 +01:00
test Graceful shutdown 2020-11-27 15:38:21 +01:00
.gitattributes Convert the documentation to Asciidoc 2016-01-14 13:37:20 +01:00
.gitignore gitignore: add examples/ dependency files 2016-05-25 12:54:12 +02:00
CONTRIBUTING.asciidoc Document how to run all test suites 2018-11-20 13:28:48 +01:00
erlang.mk Update Erlang.mk 2020-10-07 13:44:24 +02:00
LICENSE Welcome to 2017 2017-01-02 19:36:36 +01:00
Makefile Graceful shutdown 2020-11-27 15:38:21 +01:00
plugins.mk Document the commands based Websocket interface 2019-10-06 16:51:27 +02:00
README.asciidoc Add sponsor link to the README 2019-12-31 11:12:44 +01:00
rebar.config Graceful shutdown 2020-11-27 15:38:21 +01:00

= Cowboy

Cowboy is a small, fast and modern HTTP server for Erlang/OTP.

== Goals

Cowboy aims to provide a *complete* HTTP stack in a *small* code base.
It is optimized for *low latency* and *low memory usage*, in part
because it uses *binary strings*.

Cowboy provides *routing* capabilities, selectively dispatching requests
to handlers written in Erlang.

Because it uses Ranch for managing connections, Cowboy can easily be
*embedded* in any other application.

Cowboy is *clean* and *well tested* Erlang code.

== Online documentation

* https://ninenines.eu/docs/en/cowboy/2.6/guide[User guide]
* https://ninenines.eu/docs/en/cowboy/2.6/manual[Function reference]

== Offline documentation

* While still online, run `make docs`
* User guide available in `doc/` in PDF and HTML formats
* Function reference man pages available in `doc/man3/` and `doc/man7/`
* Run `make install-docs` to install man pages on your system
* Full documentation in Asciidoc available in `doc/src/`
* Examples available in `examples/`

== Getting help

* Official IRC Channel: #ninenines on irc.freenode.net
* https://github.com/ninenines/cowboy/issues[Issues tracker]
* https://ninenines.eu/services[Commercial Support]
* https://github.com/sponsors/essen[Sponsor me!]