【问题标题】:Erlang / Rebar3 - How to add an application to release but not launch it?Erlang / Rebar3 - 如何添加应用程序以发布但不启动它?
【发布时间】:2021-01-22 16:58:26
【问题描述】:

我有一个伞形项目,包括 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 的梁文件。 我知道,如果我用kernel, sasl, main_app 将 app1 和 app2 放到列表中的发布部分 - 我需要的应用程序将被添加到发布中,但它们会自动启动(我需要自己启动)!

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

提前致谢!

【问题讨论】:

    标签: erlang rebar rebar3


    【解决方案1】:

    使用{app, load} 语法:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-17
      • 2020-12-11
      • 2015-03-11
      • 2014-12-05
      • 2020-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多