gpt4 book ai didi

Erlang 简单版本与牛仔 2.0.0 不起作用

转载 作者:行者123 更新时间:2023-12-02 09:35:03 25 4
gpt4 key购买 nike

我正在使用 Erlang/OTP 20.0 和 rebar3。当我启动使用牛仔 2.0.0 的新版本时,该版本无法启动。

以下是我构建项目的步骤。怎么了?

  1. 创建发布项目

    $ rebar3 new release cowboy2
  2. 添加牛仔包

    {deps, [{cowboy, {git, "https://github.com/ninenines/cowboy.git", {tag, "2.0.0"}}}]}.
  3. 添加基本调度程序

    start(_StartType, _StartArgs) ->
    Dispatch = cowboy_router:compile([
    {'_', [
    {"/", toppage_handler, []}
    ]}
    ]),
    {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
    env => #{dispatch => Dispatch}
    }),
    cowboy2_sup:start_link().
  4. 添加处理程序。出于本示例的目的,我使用 ( https://raw.githubusercontent.com/ninenines/cowboy/master/examples/hello_world/src/toppage_handler.erl )

  5. 编译并发布

    $ rebar3 compile && rebar3 release
  6. 运行应用程序

    $ ./_build/default/rel/cowboy2/bin/cowboy2-0.1.0 console

输出

$ ./_build/default/rel/cowboy2/bin/cowboy2-0.1.0 console
Exec: /home/deimos/.asdf/installs/erlang/20.0/lib/erlang/erts-9.0/bin/erlexec
-boot /home/deimos/Dev/personal/cowboy2/_build/default/rel/cowboy2/releases/0.1.0/cowboy2
-mode embedded -boot_var ERTS_LIB_DIR /home/deimos/.asdf/installs/erlang/20.0/lib/erlang/lib
-config /home/deimos/Dev/personal/cowboy2/_build/default/rel/cowboy2/releases/0.1.0/sys.config
-args_file /home/deimos/Dev/personal/cowboy2/_build/default/rel/cowboy2/releases/0.1.0/vm.args
-pa -- console

Root: /home/deimos/Dev/personal/cowboy2/_build/default/rel/cowboy2
/home/deimos/Dev/personal/cowboy2/_build/default/rel/cowboy2
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:30] [hipe] [kernel-poll:true]


=INFO REPORT==== 11-Oct-2017::21:00:52 ===
application: cowboy2
exited: {bad_return,
{{cowboy2_app,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy_router,compile,
[[{'_',[{"/",toppage_handler,[]}]}]],
[]},
{cowboy2_app,start,2,
[{file,
"/home/deimos/Dev/personal/cowboy2/_build/default/lib/cowboy2/src/cowboy2_app.erl"},
{line,18}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,273}]}]}}}}
type: permanent
(...)
Kernel pid terminated (application_controller)
({application_start_failure,cowboy2,{bad_return,{{cowboy2_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy_router,compile,[[{'_',[{"/",toppage_handler,[]}]

Crash dump is being written to: erl_crash.dump...done

最佳答案

正如 @maze-le 指出的,问题在于牛仔应用程序未启动。解决方案是将cowboy 添加到文件apps/cowboy2/src/cowboy2.app.src 中,该文件也是由命令$rebar3 new releaseowboy2 生成的。为了完整性,我添加了该文件。

apps/cowboy2/src/cowboy2.app.src

{application, cowboy2,
[{description, "An OTP application"},
{vsn, "0.1.0"},
{registered, []},
{mod, { cowboy2_app, []}},
{applications,
[kernel,
stdlib,
cowboy
]},
{env,[]},
{modules, []},

{maintainers, []},
{licenses, ["Apache 2.0"]},
{links, []}
]}.

关于Erlang 简单版本与牛仔 2.0.0 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46699976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com