diff --git a/doc/src/guide/listeners.asciidoc b/doc/src/guide/listeners.asciidoc index 77019235..04169f9a 100644 --- a/doc/src/guide/listeners.asciidoc +++ b/doc/src/guide/listeners.asciidoc @@ -75,7 +75,7 @@ start(_Type, _Args) -> Dispatch = cowboy_router:compile([ {'_', [{"/", hello_handler, []}]} ]), - {ok, _} = cowboy:start_tls(my_http_listener, + {ok, _} = cowboy:start_tls(my_https_listener, [ {port, 8443}, {certfile, "/path/to/certfile"}, @@ -101,6 +101,19 @@ Cowboy 2.0 gets released. Compatibility with HTTP/1.0 is provided by Cowboy's HTTP/1.1 implementation. +=== Stopping the listener + +When starting listeners along with the application it is +a good idea to also stop the listener when the application +stops. This can be done by calling `cowboy:stop_listener/1` +in the application's stop function: + +[source,erlang] +---- +stop(_State) -> + ok = cowboy:stop_listener(my_http_listener). +---- + === Protocol configuration The HTTP/1.1 and HTTP/2 protocols share the same semantics; diff --git a/examples/chunked_hello_world/src/chunked_hello_world_app.erl b/examples/chunked_hello_world/src/chunked_hello_world_app.erl index 9c6eb1df..70d63f55 100644 --- a/examples/chunked_hello_world/src/chunked_hello_world_app.erl +++ b/examples/chunked_hello_world/src/chunked_hello_world_app.erl @@ -22,4 +22,4 @@ start(_Type, _Args) -> chunked_hello_world_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/compress_response/src/compress_response_app.erl b/examples/compress_response/src/compress_response_app.erl index b5cba526..b35fd6f9 100644 --- a/examples/compress_response/src/compress_response_app.erl +++ b/examples/compress_response/src/compress_response_app.erl @@ -23,4 +23,4 @@ start(_Type, _Args) -> compress_response_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/cookie/src/cookie_app.erl b/examples/cookie/src/cookie_app.erl index da086e27..358d8823 100644 --- a/examples/cookie/src/cookie_app.erl +++ b/examples/cookie/src/cookie_app.erl @@ -22,4 +22,4 @@ start(_Type, _Args) -> cookie_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/echo_get/src/echo_get_app.erl b/examples/echo_get/src/echo_get_app.erl index c2fd0dfe..5b15fb33 100644 --- a/examples/echo_get/src/echo_get_app.erl +++ b/examples/echo_get/src/echo_get_app.erl @@ -22,4 +22,4 @@ start(_Type, _Args) -> echo_get_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/echo_post/src/echo_post_app.erl b/examples/echo_post/src/echo_post_app.erl index b4547400..4a057bbc 100644 --- a/examples/echo_post/src/echo_post_app.erl +++ b/examples/echo_post/src/echo_post_app.erl @@ -22,4 +22,4 @@ start(_Type, _Args) -> echo_post_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/eventsource/src/eventsource_app.erl b/examples/eventsource/src/eventsource_app.erl index 932306ec..825f434f 100644 --- a/examples/eventsource/src/eventsource_app.erl +++ b/examples/eventsource/src/eventsource_app.erl @@ -23,4 +23,4 @@ start(_Type, _Args) -> eventsource_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/file_server/src/file_server_app.erl b/examples/file_server/src/file_server_app.erl index 89d5af00..17e73b29 100644 --- a/examples/file_server/src/file_server_app.erl +++ b/examples/file_server/src/file_server_app.erl @@ -26,4 +26,4 @@ start(_Type, _Args) -> file_server_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/hello_world/src/hello_world_app.erl b/examples/hello_world/src/hello_world_app.erl index 59229484..daa7d194 100644 --- a/examples/hello_world/src/hello_world_app.erl +++ b/examples/hello_world/src/hello_world_app.erl @@ -22,4 +22,4 @@ start(_Type, _Args) -> hello_world_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/markdown_middleware/src/markdown_middleware_app.erl b/examples/markdown_middleware/src/markdown_middleware_app.erl index 819fd53d..75b3bc7c 100644 --- a/examples/markdown_middleware/src/markdown_middleware_app.erl +++ b/examples/markdown_middleware/src/markdown_middleware_app.erl @@ -23,4 +23,4 @@ start(_Type, _Args) -> markdown_middleware_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/rest_basic_auth/src/rest_basic_auth_app.erl b/examples/rest_basic_auth/src/rest_basic_auth_app.erl index d595706e..f95dc36b 100644 --- a/examples/rest_basic_auth/src/rest_basic_auth_app.erl +++ b/examples/rest_basic_auth/src/rest_basic_auth_app.erl @@ -22,4 +22,4 @@ start(_Type, _Args) -> rest_basic_auth_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/rest_hello_world/src/rest_hello_world_app.erl b/examples/rest_hello_world/src/rest_hello_world_app.erl index 85bd9b5e..40dd890c 100644 --- a/examples/rest_hello_world/src/rest_hello_world_app.erl +++ b/examples/rest_hello_world/src/rest_hello_world_app.erl @@ -22,4 +22,4 @@ start(_Type, _Args) -> rest_hello_world_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/rest_pastebin/src/rest_pastebin_app.erl b/examples/rest_pastebin/src/rest_pastebin_app.erl index 0fbfd647..a5e7ebc5 100644 --- a/examples/rest_pastebin/src/rest_pastebin_app.erl +++ b/examples/rest_pastebin/src/rest_pastebin_app.erl @@ -22,4 +22,4 @@ start(_Type, _Args) -> rest_pastebin_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/ssl_hello_world/src/ssl_hello_world_app.erl b/examples/ssl_hello_world/src/ssl_hello_world_app.erl index 4a9122f2..959dc779 100644 --- a/examples/ssl_hello_world/src/ssl_hello_world_app.erl +++ b/examples/ssl_hello_world/src/ssl_hello_world_app.erl @@ -26,4 +26,4 @@ start(_Type, _Args) -> ssl_hello_world_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(https). diff --git a/examples/upload/src/upload_app.erl b/examples/upload/src/upload_app.erl index 2ed58048..6fb829ff 100644 --- a/examples/upload/src/upload_app.erl +++ b/examples/upload/src/upload_app.erl @@ -22,4 +22,4 @@ start(_Type, _Args) -> upload_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http). diff --git a/examples/websocket/src/websocket_app.erl b/examples/websocket/src/websocket_app.erl index 92c7edc1..babb39ea 100644 --- a/examples/websocket/src/websocket_app.erl +++ b/examples/websocket/src/websocket_app.erl @@ -23,4 +23,4 @@ start(_Type, _Args) -> websocket_sup:start_link(). stop(_State) -> - ok. + ok = cowboy:stop_listener(http).