Search code examples
erlangmnesia

How can i start mnesia from a supervisor


I have trying to find information about it everywhere and failed. Is it possible to start mnesia as a worker from a supervisor? I have tried it myself the same way I start other workers but always get error.


Solution

  • Mnesia is an application and comes with its own supervisor. You should only need to run application:start(mnesia). But if you really want to add your own supervision, you should be able to start it as a worker. However, you need to start it from your supervisor in much the same way that it is specified by the mod key in the mnesia.app file (but note that the details there have changed between OTP 19 and the upcoming OTP 20). You'll also need to ensure that its settings are loaded before it starts. You could call application:load(mnesia) yourself, or you could specify Mnesia as an included application of your own app - see http://erlang.org/doc/design_principles/included_applications.html for more info (you can probably ignore the stuff about start phases).