目前我的Erlang应用程序在escript(TCP服务器)中启动,并且所有工作都正常,因为它使用我提供的默认端口。现在我想通过escript将端口传递给应用程序,但我不知道如何。 (该应用程序运行主管)Erlang escript使用启动参数启动应用程序
script.escript
!/usr/bin/env escript
%% -*- erlang -*-
-export([main/1]).
main([UDPort, TCPort]) ->
U = list_to_integer(UDPort),
T = list_to_integer(TCPort),
app:start(), %% Want to pass T into the startup.
receive
_ -> ok
end;
...
app.erl
-module(app).
-behaviour(application).
-export([start/0, start/2, stop/0, stop/1]).
-define(PORT, 4300).
start() -> application:start(?MODULE). %% This is called by the escript.
stop() -> application:stop(?MODULE).
start (_StartType, _StartArgs) -> supervisor:start(?PORT).
stop (_State) -> ok.
我真的不知道这是可能的使用应用程序,但我认为最好只是问。