Search code examples
erlangrebar

I've build a gen_server with Erlang and rebar. Now how do I run it?


Rebar included the framework, [blah]_sup.erl and so on. I added my one external dependency to rebar.config. I added a file to src/, which is a gen_server that handles most of the work. I've added that gen_server file to [blah]_sup.erl so the gen_server starts as a child, and starts when the app starts. Of course I've compiled everything with rebar compile.

What do I do now? I don't know how to start the app!


Solution

  • As Jr0 suggests in the comment you run:

    application:start(blah).

    However, you need to make sure you add the dependency path first:

    code:add_patha("../deps/<dependency name goes here>/ebin").

    and make sure it' started:

    {ok, _} = application:ensure_all_started(<dependency name goes here>).

    Personally I tend to make a stand-alone module called blah.erl that does the above for me and just call that.