Starting mnesia with a webmachine app

I have a webmachine app that uses Mnesia as an in-memory DB. To begin with, I was just calling mnesia:start() in the erlang terminal provided after running But, after forgetting to start it a couple of times, I looked for a better solution.

My first stop, the internet, didn’t provide me with any answers (either it should be obvious, or I was using the wrong keywords!). So I decided to try adding it to the dependency list in my application resource file (.app.src).

{application, restbucks,
  {description, "restbucks"},
  {vsn, "1"},
  {modules, []},
  {registered, []},
  {applications, [
                  ... snip ...
  {mod, { restbucks_app, []}},
  {env, []}

Unfortunately, that didn’t seem to have any effect whatsoever.

Luckily, I’d discovered through my adventures with eunit, that erl can take a number of arguments (-s) that will be executed when starting. So I modified my script appropriately:

exec erl -pa $PWD/ebin $PWD/deps/*/ebin -boot start_sasl -s mnesia start -s reloader -s restbucks

Whether this is a good idea remains to be seen, but it seems to work!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s