繁体   English   中英

从命令行启动erlang应用程序时出现问题

[英]Problems with starting an erlang application from the command line

我正在尝试从命令行启动应用程序。 该应用程序基本上是OTP兼容的TCP服务器,并且从外壳启动时运行良好。 但是,从命令行启动时,它实际上不会启动。

我的所有文件都位于兼容的文件夹结构中,即\\ src和二进制文件\\ ebin中的源。 我已经在.erlang文件中设置了路径

code:add_patha("./ebin").

而被调用的功能在此模块中

-module(wotsuke_geolocation_lookup_server).
-behaviour(application).

-export([start/0, start/2, stop/1]).

start() -> 
    event_dbs:start(),
    wotsuke_server_sup:start_link().

start(_Type, _Args) ->
    event_dbs:start(),
    wotsuke_server_sup:start_link().

stop(_State) ->
    ok.

我还(冗余地)添加了一个start / 0(由于将来的功能需要使用args,所以我使用了start / 2),因为以参数开头从未奏效。 现在,当我运行时:

erl -run wotsuke_geolocation_lookup_server start [] []

我懂了

Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]

{"init terminating in do_boot",{undef,[{wotsuke_geolocation_lookup_server,start,[["[]","[]"]],[]},{init,start_it,1,[]},{init,start_em,1,[]}]}}

Crash dump is being written to: erl_crash.dump...done
init terminating in do_boot ()

表示找不到模块/功能。 因此,我使用了冗余启动/ 0

erl -run wotsuke_geolocation_lookup_server start

并获得:

Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.0  (abort with ^G)
1> 

基本上什么都没有启动(没有返回进程ID)。 我尝试连接到服务器,并在服务器关闭时得到典型的答案。 我还通过使用-pa选项将erl强制到ebin文件夹来进行尝试。 同上。

因为这是我第一次尝试从命令行运行erlang应用程序(以使其妖魔化),所以我一无所知。

谢谢你的帮助。

添加:不确定是否有帮助,我也添加了erlang应用程序代码

{application, wotsuke_geolocation_lookup_server,
   [{description, "Wotsuke Geolocation lookup server"},
    {vsn, "0.1.0"},
    {modules, [tcpserver_otp_backend, ets_methods, data_packing, data_formats, event_timings, logger, event_dbs,
                    obsolete_data_clean_ad, obsolete_data_clean, wotsuke_data_input, wotsuke_logger, wotsuke_server_sup, data_retrieve, wotsuke_data_output, user_event_dbs,
                    event_areas]},
    {registered, [wotsuke_data_input, wotsuke_server_sup, wotsuke_logger, wotsuke_data_output]},
    {applications, [kernel, stdlib, mnesia]},
    {env, []},
    {mod, {bsc, []}}]}.

更新:解决了一个问题。 命令的问题

erl -run wotsuke_geolocation_lookup_server start [] []

实际上是由于erl期望仅指定模块才开始/ 0或如果还指定了功能则为1的事实。 使[] []被视为[[],[]]。

显然,我的问题是由于无法通过命令行将管理员作为标准功能来启动,而是通过使用application:start来启动。 因此,我已经通过使用该应用程序并在命令行上执行解决了我的问题

erl (options) eval "application:start(...)"

根据http://erlang.org/doc/man/init.html可以 ,运行执行的功能应为1。您可以定义init([Application, Type]) ,该函数调用start / 2,然后使用erl -run wotsuke_geolocation_lookup_server init [] []运行erl -run wotsuke_geolocation_lookup_server init [] []

暂无
暂无

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

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