Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use ranch:start_listener

  • Loading branch information...
commit 1ce583a826321d3b760ab2f6c962bcb9ced420b9 1 parent df90895
@benoitc benoitc authored
View
10 apps/couch_httpd/src/couch_httpd.erl
@@ -137,13 +137,13 @@ server_options() ->
child_spec(http) ->
Port = list_to_integer(couch_config:get("httpd", "port", "5984")),
- child_spec(http, ranch_tcp, Port, server_options());
+ child_spec(ranch_tcp, Port, server_options());
child_spec(https) ->
Options = server_options() ++ ssl_options(),
Port = list_to_integer(couch_config:get("ssl", "port", "6984")),
- child_spec(https, ranch_ssl, Port, Options).
+ child_spec(ranch_ssl, Port, Options).
-child_spec(Name, Transport, Port, TransOpts0) ->
+child_spec(Transport, Port, TransOpts0) ->
{ok, ProtoOpts} = get_protocol_options(),
set_auth_handlers(),
NbAcceptors = list_to_integer(
@@ -151,8 +151,8 @@ child_spec(Name, Transport, Port, TransOpts0) ->
),
TransOpts = [{port, Port}|TransOpts0],
- ranch:child_spec(Name, NbAcceptors, Transport, TransOpts,
- couch_httpd_protocol, ProtoOpts).
+
+ {NbAcceptors, Transport, TransOpts, ProtoOpts}.
get_protocol_options() ->
DefaultSpec = "{couch_httpd_db, handle_request}",
View
6 apps/couch_httpd/src/couch_httpd_config.erl
@@ -36,7 +36,11 @@ reload_listener(Ref) ->
ranch:set_max_connections(Ref, NbAcceptors).
start_listener(Ref) ->
- supervisor:start_child(ranch_sup, couch_httpd:child_spec(Ref)).
+ {Name, NbAcceptors, Transport,
+ TransOpts, ProtoOpts} = couch_httpd:child_spec(Ref),
+
+ ranch:start_listener(Name, NbAcceptors, Transport, TransOpts,
+ couch_httpd_protocol, ProtoOpts).
stop_listener(Ref) ->
ranch:stop_listener(Ref).
View
8 apps/couch_httpd/src/couch_httpd_vhosts_sup.erl
@@ -36,9 +36,11 @@ start_link() ->
start_listeners([]) ->
ok;
-start_listeners([Binding | Rest]) ->
- {ok, _} = supervisor:start_child(ranch_sup,
- couch_httpd:child_spec(Binding)),
+start_listeners([Ref | Rest]) ->
+ {NbAcceptors, Transport, TransOpts, ProtoOpts} = couch_httpd:child_spec(Ref),
+ {ok, _} = ranch:start_listener(Ref, NbAcceptors, Transport,
+ TransOpts, couch_httpd_protocol,
+ ProtoOpts),
start_listeners(Rest).
Please sign in to comment.
Something went wrong with that request. Please try again.