简体   繁体   English

Erlang依赖关系未启动错误

[英]Erlang Dependency Not Started Error

I am trying to run a start script but I end up with the following error. 我正在尝试运行启动脚本,但最终出现以下错误。

{"init terminating in do_boot",{{case_clause,{error,{not_started,ranch}}},[{egs,ensure_started,1,[{file,"src/egs.erl"},{line,84}]},{egs,start,0,[{file,"src/egs.erl"},{line,49}]},{init,start_it,1,[]},{init,start_em,1,[]}]}}

I can compile the entire folder with multiple dependencies and this is the only one with an error. 我可以编译具有多个依赖项的整个文件夹,这是唯一一个出错的文件夹。 I use 'make' to compile and it is supposed to be 'make run' to run but that isn't working. 我使用“ make”进行编译,应该以“ make run”的方式运行,但这是行不通的。 Is that why I am getting this error? 这就是为什么我会收到此错误? Any ideas on how to fix it would be greatly appreciated. 任何有关如何解决它的想法将不胜感激。

The file where I get the error from is below. 下面是我收到错误的文件。

-module(egs).
-export([start/0, stop/0, global/1, warp/4, warp/5]). %% API.

%% Player and account-related types.

-type gid() :: 0..16#ffffffff.
-type lid() :: 0..1023 | 16#ffff.
-type character_slot() :: 0..3.
-export_type([gid/0, lid/0, character_slot/0]).

%% Location related types.

-type uniid() :: 21 | 26..254 | 16#ffffffff.
-type questid() :: 0..16#ffffffff. %% @todo What's the real max?
-type zoneid() :: 0..16#ffff. %% @todo What's the real max?
-type mapid() :: 0..9999.
-type entryid() :: 0..16#ffff. %% @todo What's the real max?
-type area() :: {questid(), zoneid(), mapid()}. %% @todo Probably remove later.
-type position() :: {X::float(), Y::float(), Z::float(), Dir::float()}.
-export_type([uniid/0, questid/0, zoneid/0, mapid/0, entryid/0,
area/0, position/0]).

%% API.

-spec start() -> ok.
start() ->
ensure_started(crypto),
ensure_started(public_key),
ensure_started(ssl),
ensure_started(cowboy),
ensure_started(ranch),
application:start(egs).

-spec stop() -> ok.
stop() ->
Res = application:stop(egs),
ok = application:stop(cowboy),
ok = application:stop(ranch),
ok = application:stop(ssl),
ok = application:stop(public_key),
ok = application:stop(crypto),
Res.

%% @doc Send a global message.
-spec global(string()) -> ok.
global(Message) when length(Message) > 511 ->
io:format("global: message too long~n");
global(Message) ->
egs_users:broadcast_all({egs, notice, top, Message}).

%% @doc Warp all players to a new map.
-spec warp(questid(), zoneid(), mapid(), entryid()) -> ok.
warp(QuestID, ZoneID, MapID, EntryID) ->
egs_users:broadcast_all({egs, warp, QuestID, ZoneID, MapID, EntryID}).

%% @doc Warp one player to a new map.
-spec warp(gid(), questid(), zoneid(), mapid(), entryid()) -> ok.
warp(GID, QuestID, ZoneID, MapID, EntryID) ->
egs_users:broadcast({egs, warp, QuestID, ZoneID, MapID, EntryID}, [GID]).

%% Internal.

-spec ensure_started(module()) -> ok.
ensure_started(App) ->
case application:start(App) of
ok -> ok;
{error, {already_started, App}} -> ok
end.

The order of application startup is important. 应用程序启动的顺序很重要。 In particular, cowboy depends on ranch and crypto . 特别是, cowboy依赖ranchcrypto Also, public_key depends on crypto and must be started before ssl . 此外, public_key取决于crypto ,必须在ssl之前启动。 The correct start order is: 正确的启动顺序为:

ok = application:start(crypto),
ok = application:start(public_key),
ok = application:start(ssl),
ok = application:start(ranch),
ok = application:start(cowboy),
ok = application:start(egs).

For applications built with Rebar, the startup dependencies are listed in [app]/src/[app].app.src . 对于使用Rebar构建的应用程序,启动依赖项在[app]/src/[app].app.src See the LYSE chapter . 参见LYSE章节

The reason it didn't work out of the box is probably that EGS depends on Cowboy's master branch, which quite recently introduced Ranch as a dependency. 它之所以开箱即用,可能是因为EGS依赖于Cowboy的master分支,该分支最近才引入Ranch作为依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM