Search code examples
erlangstartup

Run code at startup of an Erlang Application


I would like to run some code at the startup of an Erlang Application. Is's about to connect to the Database and initialise some things. How can i do this?


Solution

  • You can call the desired functions from the start/2 function of your application's entry module (which implements -behaviour(application) in it and is specified in your *.app or *.app.src if you use rebar). After you create a release, the start/2 function will be executed when starting the application.

    More information about making a release can be found here (assuming rebar is used).