2

我有一个伞形项目,包括 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"}
    ]}
  ]}
]}.

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

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

提前致谢!

4

1 回答 1

4

使用{app, load}语法:

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

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

于 2020-10-07T17:27:55.617 回答