Erlang / Rebar3 - 如何添加要发布但不启动的应用程序?

Nic*_*Saw 2 erlang rebar rebar3

我有一个伞式项目,包括 main_app、app1、app2。main_app 可以单独工作,也可以与 app1 和 app2 一起使用并管理它们。

关于启动 app1 和 app2 的决定是在外部(特殊配置文件,由用户填写)。

我使用 rebar.config 的一部分:

{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"}
    ]}
  ]}
]}.
Run Code Online (Sandbox Code Playgroud)

如果我使用sudo rebar3 shell- 我可以管理app1和app2。但是,如果我通过 - 打包发行版,sudo rebar3 as prod tar我会得到一个 tar 存档,其中不包含 app1 和 app2 的 Beam 文件。我知道,如果我将 app1 和 app2 放入列表中的发布部分kernel, sasl, main_app- 我需要的应用程序将被添加到发布中,但它们将自动启动(我需要自己启动)!

如何配置 rebar 以将所有库或应用程序添加到 tar 版本,但不在启动 main_app 期间启动它们?

提前致谢!

Jos*_*é M 5

使用{app, load}语法:

{relx, [
    {release, { Project, Version }, [
        {app1, load}
...
Run Code Online (Sandbox Code Playgroud)

这样,应用程序会被加载但不会启动。如果您既不想加载也不想启动应用程序,请使用{app, none}(但代码仍会加载)。