[erlang-questions] Application setup

Sean Hinde sean.hinde@REDACTED
Sat Jun 16 16:54:59 CEST 2007

On 16 Jun 2007, at 15:08, Kirill Zaborski wrote:

> What is the recommended way to do application setup in OTP? I mean  
> what if my application requires some initialization steps before  
> running? E.g. it requires some mnesia tables created.
> As I understand for release upgrade I can do this using *.appup  
> files in OTP Design Principles I see only example of process state  
> modification is it OK to transform mnesia tables in code_change/3?
> And what do I when I install my application first time?

I would suggest to define some record that all parts of your system  
can use to define table definitions, then at system startup doing  
something like:

1. Find the list of all table definition records.
2. Attempt to create all tables.
3. Any that are already created (return {aborted,{already_exists,_}})  
compare the fields and if different do a table transform.

This way you not only get the tables created at startup, but you also  
get auto upgrade.

You could do this during startup of one of your first applications.


More information about the erlang-questions mailing list