How to stop third-party Erlang applications

I am in the process of writing my first erlang application, and I do not yet understand some parts of the erlang ecosystem and how it should be done. For example, if my application depends on some other applications, what is the way to start and stop them right away? In fact, I figured out how to get started, just put the calls application:start/1into the function of start/2the application module:

-module(myapp).
-behaviour(application).

-export([start/0, start/2, stop/1]).

start(_Type, _StartArgs) ->
    ok = application:start(ssl),
    ok = application:start(inets),
    ok = application:start(log4erl),
    myapp_sup:start_link().

stop(_State) ->
    ok.

But when I tried to put the appropriate calls application:stop/1into the function myapp:stop/1and was called from the erlang shell application:stop(myapp), then later it just stops responding to any command.

+3
source share
3 answers

Reading from white paper:

stop/1 . , , , .

.

, , .app, , ( ) .

+4

erlware.org sinan faxien Erlang. OTP , , . http://www.manning.com/logan/ , pdf.

"" - .

+3

You already have some good suggestions. Let me just add an explanation of the problem you are seeing: your callback function stopis called synchronously by the application controller, i.e. the application controller will not do anything until your function returns. But you ask the application manager to stop some other applications - and the two processes are at a standstill, waiting for each other.

0
source

Source: https://habr.com/ru/post/1733746/


All Articles