[erlang-questions] application:is_started?

Serge Aleynikov saleyn@REDACTED
Tue Oct 16 14:24:02 CEST 2007


YC wrote:
> Hi all -
> I've noticed that the application library doesn't provide an equivalent of a
> is_started function, so I'm wondering whether there is an idiom to check
> whether an app is running:
> 
> 1) Are functions expected to derived the result from checking {ok, Pid} or
> {error, already_started} everytime they want to use an application? or

1> App = stdlib.
stdlib
2> [T || {A, _, _} = T <- application:which_applications(), A =:= App].
[{stdlib,"ERTS  CXC 138 10","1.14.4"}]

If you need to expect if an application is running from within the
modules of that application, use application:get_application/0.

> 2) Are functions expected to simply call the interface provided by the app
> w/out regard to whether the app is started? or

I would say yes - it is the job of a proper boot script and following
design principles on application and supervisor behaviors to ensure that
your run-time environment is started as needed.

> 3) Are there ways to ensure the application in question is started.

Use a boot script (produced from a *.rel file using erlc), and start the
emulator with a "-boot your_boot_script" option.

> I'm thinking of library modules where each function can be called
> independently but depend on some underlying applications.  An example is a
> wrapper onto of the crypto app - because crypto needs to be started, either
> I have to make the wrapper into another server or I would have to test
> whether the crypto app is started on every function.
> 
> Would love to see what type of code structure is "good" - any thoughts are
> appreciated.
> 
> Thanks,
> yc
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions





More information about the erlang-questions mailing list