rebar3 - 如何让 Erlang 应用程序在启动 rebar3 时运行

标签 rebar3

我可以通过执行 application:start(lager) 后跟 application:start(myapp) 从 rebar3 shell 手动启动应用程序。我希望这种情况发生而不必输入它,例如通过执行一个 shell 脚本来告诉 rebar3 运行这些命令。这可能吗?

最佳答案

假设您想在开发期间运行应用程序,您可以这样做:

  • 或者您在命令行中指定应用程序,如下所示:rebar3 shell --apps lager myapp
  • 或者您在 rebar.config {shell, [{apps, [lager, myapp]}]}. 中指定,然后简单地使用 rebar3 shell 运行它。例如,我有一个名为 tron 的应用程序,并且在我的 rebar.config 中有以下行: {shell, [{apps, [kernel,stdlib,cowboy,lager,tron]}]} 。现在,当我运行 rebar3 shell 时,我的 erlang 应用程序与所有依赖项一起启动。

  • 有关 rebar3 shell 以及如何使用它的更多信息,请参阅来自创建者的 this 很棒的博客文章,或官方文档 here

    但是您可能知道,运行应用程序进行部署的正确方法是首先构建一个 版本 然后简单地将其作为可执行文件运行(我已经有一段时间没有构建一个版本了,但那时它比听起来要难,不幸的是!虽然看起来 rebar3 可能使它变得更容易一些: rebar3 releases

    关于rebar3 - 如何让 Erlang 应用程序在启动 rebar3 时运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40211752/

    相关文章:

    erlang - 如何在 Erlang escript 中设置代理?

    erlang - 如何将新的 Erlang 应用程序添加到 Rebar3 伞式项目?

    bash - Rebar3 和 Erlang -heart 标志

    erlang - -include_lib 找不到我的库

    erlang - Erlang 20.2 的语法错误

    phoenix-framework - Phoenix : Running mix ecto. 创建错误编译牧场依赖

    elixir - 编译 riak_core 项目时,Mix 在 deps.compile 上挂起

    erlang - 使用Rebar3 Common Test在include文件夹中找不到hrl文件,但eunit却找到