[erlang-questions] Mnesia best practices

Vance Shipley <>
Wed Sep 24 21:22:40 CEST 2008


The release resource file (.rel) defines the what applications are
included in a release package (.tar.gz).  When a release package is
created a .boot file is generated.  When the run time system is started
with 'erl -boot foo.boot' all the applications required by the foo 
release will be started.  This is best handled by following the 
Embedded Systems User's Guide(*) so that your application(s) can be
run out of the operating system's initializatiuon at boot time, or
with start(+).

You write an application resource file (.app)(~) to specify the 
resources needed by your application.  This includes the applications
which must be started ({applications, Apps}) or loaded
({included_applications}) beforehand.  You also specify how your 
application will be started ({mod, Start}).  You may define application
environment variables here as well.  For example you may define the 
default locations of some resources here with {env, Env}.  For example:
{env, [{foo_data, "data/foo"}]}.  In your application you access the
environment variable using application:get_env(foo_data).

When the run time system is started with `erl -config sys` it will
read a configuration file named sys.config(^) (this is done as part
of starting an embedded system).  In your configuration file you may
overide, or just create, environment variables for any of the
applications.  The sys.config file is where you want to do local
configuration.  You would overide your default foo_file value with
the locally defined location of that resource.

Now here's the answer to your question; you overide mnesia's application
environment variables in your configuration file.  The mnesia environment
variables, or configuration parameters, are documented at the bottom of
the mnesia page:  http://erlang.org/doc/apps/mnesia/index.html.

An example sys.config file:

[{mnesia, [{dir, "db"}]},
 {foo, [{foo_file, "/tmp/foo"}]}].


(*) http://erlang.org/doc/embedded/part_frame.html
(+) http://erlang.org/doc/apps/erts/index.html
(~) http://erlang.org/doc/apps/kernel/index.html
(^) http://erlang.org/doc/apps/kernel/index.html

On Wed, Sep 24, 2008 at 03:56:03PM +0100,  wrote:
}  Can you be more specific please? I have had a look at the OTP Design 
}  principles i.e. release handling as suggested.
}  Although it mentions target systems and building a release (.rel which 
}  looks good) it doesn't specify how I might specify the working Mnesia 
}  instance which I also want starting?

More information about the erlang-questions mailing list