erlangerlang-otpgen-servercowboyrebar3

Issue with running a compiled rebar3 erlang application with erl -pa


An erlang OTP application (nerlnetApp) that depends on cowboy compiled and run successfully when executed using the command: rebar3 shell, from application directory.

However, erlang shell cannot run in CI environment and therefore we decide to run it using the following method:

erl -pa jsx/ebin ranch/ebin cowlib/ebin cowboy/ebin nerlnetApp/ebin -eval "nerlnetApp_app:start(a,b)."

This command generates the following error:

{"init terminating in do_boot",
{noproc,{gen_server,call,[ranch_sup,{start_child,{{ranch_listener_sup,nerlnetInitiator},
{ranch_listener_sup,start_link,[nerlnetInitiator,ranch_tcp,#{connection_type=>supervisor,socket_opts=>[{port,8484}]},cowboy_clear,#{connection_type=>supervisor,env=>#{dispatch=>[{'_',[],[{[<<"updateJsonPath">>],[],jsonHandler,[<0.9.0>]},{[<<"isNerlnetDevice">>],[],iotHandler,[<0.9.0>]}]}]}}]},permanent,infinity,supervisor,[ranch_listener_sup]}},infinity]}}}

Link to nerlnetInitiator where init_cowboy_start_clear fails.
Link to application directory with rebar.config file.


Solution

  • The function nerlnetApp_app:start/2 is the callback function for the application behaviour - it's not meant to be called directly. Try this instead:

    -eval "application:ensure_all_started(nerlnetApp, permanent)."
    

    That will start all dependencies, including ranch, before starting the application itself. That should avoid the noproc error, which suggests that there is no running process named ranch_sup.