diff options
author | j.uhlig <[email protected]> | 2018-03-13 09:31:20 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-03-14 16:04:15 +0100 |
commit | fa608621bfedbb981657d2d09e2b321dddc0ad8e (patch) | |
tree | 13efb8de52cb24c449e3defb26ac40da447d8923 /test/embedded_sup.erl | |
parent | 132dd4dfee8a0cf6f2bd05d21538898bdbbc70ab (diff) | |
download | ranch-fa608621bfedbb981657d2d09e2b321dddc0ad8e.tar.gz ranch-fa608621bfedbb981657d2d09e2b321dddc0ad8e.tar.bz2 ranch-fa608621bfedbb981657d2d09e2b321dddc0ad8e.zip |
Fix ranch:info/0 and ranch:procs/2 in embedded mode
Diffstat (limited to 'test/embedded_sup.erl')
-rw-r--r-- | test/embedded_sup.erl | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/embedded_sup.erl b/test/embedded_sup.erl new file mode 100644 index 0000000..52275e0 --- /dev/null +++ b/test/embedded_sup.erl @@ -0,0 +1,28 @@ +-module(embedded_sup). +-behaviour(supervisor). +-export([init/1]). + +-export([start_link/0]). +-export([stop/1]). +-export([start_listener/6]). +-export([stop_listener/2]). + +start_link() -> + supervisor:start_link(?MODULE, []). + +stop(SupPid) -> + erlang:exit(SupPid, normal). + +init([]) -> + {ok, {{one_for_one, 10, 10}, []}}. + +start_listener(SupPid, Ref, Transport, TransOpts, Protocol, ProtoOpts) -> + supervisor:start_child( + SupPid, + ranch:child_spec(Ref, Transport, TransOpts, Protocol, ProtoOpts) + ). + +stop_listener(SupPid, Ref) -> + ok = supervisor:terminate_child(SupPid, {ranch_listener_sup, Ref}), + ok = supervisor:delete_child(SupPid, {ranch_listener_sup, Ref}), + ranch_server:cleanup_listener_opts(Ref). |