[erlang-questions] Stopping Application in erlang.
Magnus Henoch
magnus@REDACTED
Mon Mar 30 12:49:46 CEST 2015
harsha sri <harsha.pic@REDACTED> writes:
> I am running appication with Supervisor & Worker model. Can
> anybody guide me through how to stop application or restart my
> application.
>
> Below is my application file:
>
> -module(uclient).
>
> -behaviour(application).
>
> -export([start/2, stop/1]).
>
> -record(state, {pid}).
>
> start(normal, []) ->
> case uclient_sup:start_link({uclient_sup}) of
> {ok, Pid} -> {ok, Pid};
> Error -> Error
> end.
> %%uclient_sup:start_link({uclient_sup}).
>
> stop(_State) ->
> ok.
>
>
> Tried to stop application from erl command line, but getting
> error as below:
>
> uclient:stop().
> ** exception error: undefined function uclient:stop/0
The function uclient:stop/1 in your application module is just a
callback module, that is supposed to do any application-specific
cleanup before the application is stopped. In most cases, it will
look just like yours in the example above: it does nothing.
The real work of stopping an application is stopping the
supervision tree and all the linked processes. For that, you need
application:stop/1:
application:stop(uclient).
Regards,
Magnus
More information about the erlang-questions
mailing list