簡體   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