[erlang-questions] Can I stop an application from within one of its servers?
Ulf Wiger
ulf@REDACTED
Mon Nov 12 09:56:15 CET 2007
Calling init:stop() is decidedly less brutal than erlang:halt().
While you _can_ call application:stop(A) from within the application
itself, it's not very pretty. For one thing, application:stop/1 is
synchronous, so the calling process will be blocked while waiting for
the call to complete, but one step in its completion is that the
supervisor of the caller will try to shut it down gracefully. This will
not work, and the caller will be brutally killed. The application
will still be stopped, but not without some commotion.
Init:stop() is not synchronous, and gives the applications a chance
to properly prepare for the shutdown (e.g. closing dets files,etc.)
BR,
Ulf W
2007/11/12, Anthony Shipman <als@REDACTED>:
> I have a node that I want to shut down by sending a message to its central
> gen_server. What's the best way to do this? At the moment I have the
> gen_server call application:stop() which eventually calls erlang:halt().
> Calling this from within the callback module of an gen_server seems a bit
> brutal.
>
> --
> Anthony Shipman Mamas don't let your babies
> als@REDACTED grow up to be outsourced.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
More information about the erlang-questions
mailing list