Cowboy on Erlang crashes on shutdown

I'm getting a lot of errors on shutdown of my Erlang vm related to my cowboy handlers. I've got a simple_one_for_one supervisor running a start_listeners() function that runs cowboy:start_http().

Everything starts, no errors, handles requests normally.

If I shutdown the erlang VM, I get:

[error] Supervisor bitter_rpc_sup had child bitter_rpc_http_id started with bitter_rpc_sup:start_listeners() at undefined exit with reason killed in context shutdown_error

And a bunch of other errors related to the cowboy processes being killed and terminating abnormally. Does cowboy not follow OTP conventions for shutdown? Is there a way for me to intercept the shutdown at the supervisor and manually shut down all of the cowboy processes / ranch pool?

Where should I be looking to try and squash this error?


您可以创建牧场孩子并将其添加到您的主管中:

init([]) ->
    %% define Ref, NbAcceptors, IP, Port, Dispatch
    ...
    WebChild = ranch:child_spec(Ref,
                                NbAcceptors,
                                ranch_tcp,
                                [{ip, IP}, {port, Port}],
                                cowboy_protocol,
                                [{env, [{dispatch, Dispatch}]}]),
    {ok, {{one_for_one, 10, 10}, [WebChild]}}.

Taking a hard look at the included Cowboy examples, the http server isn't supervised directly, but is running under the Cowboy application.

So I changed the supervisor for my rpc daemon to do nothing:

init([]) ->
    Procs = [],
    {ok, {{one_for_one, 10, 10}, Procs}}.

and instantiated the cowboy dispatcher in the main process, returning the empty supervisor from start(,)

链接地址: http://www.djcxy.com/p/38206.html

上一篇: 如何自动删除动态主管中已终止子女的规格

下一篇: Erlang上的牛仔在关机时崩溃