作为依赖项启动 GProc
Start GProc as a dependency
我正在尝试将 gproc 作为应用程序中的 dependency 启动,但它失败了:
{error,{not_started,gproc}}
这是我的app.src文件,Rebar3编译时使用的文件:
{application, myapp,
[{description, "MyApp"},
{vsn, "0.1.0"},
{registered, []},
{mod, { my_app, []}},
{applications,
[kernel,
stdlib,
sasl,
gproc <--- Dependency, and is compiled with Rebar3
]},
{env,[]},
{modules, []},
{maintainers, []},
{licenses, []},
{links, []}
]}.
从 shell 开始,然后是 application:start(gproc).
,然后是 application:start(myapp).
,一切都很顺利。我不明白为什么...
可能是因为某种竞争条件?
shell 开始于:
erl -pa _build/default/lib/*/ebin -boot start_sasl -eval "application:start(myapp)"
编辑: 当使用 rebar3 shell
时一切正常,与我使用的 shell 命令有什么区别?
使用
application:ensure_all_started(myapp).
普通 start
尝试仅启动请求的应用程序,仅验证依赖项已经 运行。
文档:
-
Starts Application. If it is not loaded, the application controller first loads it using load/1. It ensures that any included applications are loaded, but does not start them. That is assumed to be taken care of in the code for Application.
application:ensure_all_started/1
:
Equivalent to calling start/1,2 repeatedly on all dependencies that are not yet started for an application
我正在尝试将 gproc 作为应用程序中的 dependency 启动,但它失败了:
{error,{not_started,gproc}}
这是我的app.src文件,Rebar3编译时使用的文件:
{application, myapp,
[{description, "MyApp"},
{vsn, "0.1.0"},
{registered, []},
{mod, { my_app, []}},
{applications,
[kernel,
stdlib,
sasl,
gproc <--- Dependency, and is compiled with Rebar3
]},
{env,[]},
{modules, []},
{maintainers, []},
{licenses, []},
{links, []}
]}.
从 shell 开始,然后是 application:start(gproc).
,然后是 application:start(myapp).
,一切都很顺利。我不明白为什么...
可能是因为某种竞争条件?
shell 开始于:
erl -pa _build/default/lib/*/ebin -boot start_sasl -eval "application:start(myapp)"
编辑: 当使用 rebar3 shell
时一切正常,与我使用的 shell 命令有什么区别?
使用
application:ensure_all_started(myapp).
普通 start
尝试仅启动请求的应用程序,仅验证依赖项已经 运行。
文档:
-
Starts Application. If it is not loaded, the application controller first loads it using load/1. It ensures that any included applications are loaded, but does not start them. That is assumed to be taken care of in the code for Application.
application:ensure_all_started/1
:Equivalent to calling start/1,2 repeatedly on all dependencies that are not yet started for an application