Erlang / Rebar3 - How to add an application to release but not launch it?

949 views Asked by At

I have an umbrella project, includes main_app, app1, app2. main_app can work singe, or can work with and manage app1 and app2.

The decision about the launching of app1 and app2 is on external side (special config file, filled by a user).

I use rebar.config, part of it:

{lib_dirs, ["apps"]}.
{sub_dirs, [
  "apps/main_app",
  "apps/app1",
  "apps/app2"
]}.

{relx, [{release, {main_app, "0.8.6"},
         [kernel,
          sasl,
          main_app]},
        {sys_config,  "./config/sys.config"},
        {vm_args,     "./config/vm.args"},
        {dev_mode, true},
        {include_src, true},
        {include_erts, false},
        {extended_start_script, true}]
}.

{profiles, [
  {prod, [
    {relx, [
      {dev_mode, false},
      {include_erts, false},
      {include_src, false},
      {sys_config,  "./config/prod_sys.config"},
      {vm_args,     "./config/prod_vm.args"}
    ]}
  ]}
]}.

If I use sudo rebar3 shell - I can manage app1 and app2. But if I pack a release by sudo rebar3 as prod tar - I get a tar archive which does not include beam files of app1 and app2. I know, if I put app1 and app2 to release section in the list with kernel, sasl, main_app - my needed apps will be added to release, but they will be automatically launched (I need to launch by myself)!

How to configure rebar for adding all the libraries or applications to tar release, but not to launch them during starting main_app?

Thanks in advance!

1

There are 1 answers

0
José M On BEST ANSWER

Use the {app, load} syntax:

{relx, [
    {release, { Project, Version }, [
        {app1, load}
...

That way, the application is loaded but not started. If you want to neither load nor start the application, use {app, none} (the code is still loaded, though).