I've never really used the .app
files for my projects. I understand those are required for loading an application through the application
module.
Is there another use of such files?
I've never really used the .app
files for my projects. I understand those are required for loading an application through the application
module.
Is there another use of such files?
They're used for when building releases (with *.rel to generate boot scripts). I recommend just starting with the *.app file and the application behaviour callback though. As for starting with OTP. It is a nice sweet spot in development to do:
-module(foo).
-export([start/0]).
start() ->
[application:start(A) || A <- [sasl, inets, x, y, etc]].
to start all the applications you depend on having running for your application with a simple
$ erl -s foo
-mnesia dir '"/some/path"'
to erl, it is accessed by the mnesia application as application:get_env(mnesia, dir)
. If you define an application called foo
, you can pass -foo key 'some-Erlang-literal'
to erl. The *.app file can contain defaults in the env
section, the *.rel file overrides them, and the command line overrides that.Some additional features of Erlang applications that I don't know well:
Eventually you will begin to want to start your application set in a more structured way, and that is when the whole release / boot-script is going to become more understandable. Or the opposite, you will think it is overkill for you specific needs. Just start with a simple *.app and a module with the application behaviour callbacks. You wont look back.
The *.app along with the *.rel file is used to generate boot scripts. A boot script is used to automatically launch my application when erlang is started up. An application resource file describes what applications need to be running before my application can be launched. For instance, if I use mnesia and indicate that in the .app file for my application, when I generate a boot script and use it to start my application it will start mnesia for me when starting my own application.
While you may get automatic dependency installation/handling with other package managers the boot script is useful for managing dependencies in the startup of your application which is important in an OTP application setup.
note: applications in otp refers to a bundle of running processes and/or code. applications can depend on other applications in a number of ways. Either they require the code to be installed or they require the application to be running.