[HCoop-Help] Elixir/Erlang Applications

dch at jsonified.com dch at jsonified.com
Mon May 4 04:07:44 EDT 2015


On Mon, 4 May 2015, at 07:47 AM, Jeffrey Drake wrote:
> I have attempted to deploy a simple application written in Elixir using
> the Phoenix framework, which ultimately uses the erlang vm. 
> 
> I cannot figure out exactly what is going wrong.
> 
> I have given the daemon user write access to a logs directory and scratch
> folder (although I cannot guarantee this is being used). I have built it
> on a debian wheezy vm, and packaged it with a mix release which includes
> everything to run it.
> 
> The shell script I made is based on phoenix deployment instructions and
> hcoop guides:
> 
> > #!/bin/sh
> > 
> > export MIX_ENV=prod
> > export PORT=51666
> > export COOKIE=$HOME/apps/gpsapp/scratch/.erlang.cookie
> > 
> > k5start -t -U -f /etc/keytabs/user.daemon/drakej -- gpsapp/bin/gpsapp $1
> > 
> 
> (where $1 is start, stop, etc.)
> 
> But when I run it, I get an error that seems to indicate it can’t listen.
> I have tried my user and the daemon user. The port 51666 is registered on
> the control panel. 
> 
> Has anyone encountered a problem like this?
> 
> - Jeff.
> 
> The output follows.
> > 
> > drakej at bog:~/apps$ ./gpsapp.sh console
> > Kerberos initialization for drakej/daemon at HCOOP.NET
> > Exec: /afs/hcoop.net/user/d/dr/drakej/apps/gpsapp/erts-6.4/bin/erlexec -boot /afs/hcoop.net/user/d/dr/drakej/apps/gpsapp/releases/0.0.1/gpsapp -boot_var ERTS_LIB_DIR /afs/hcoop.net/user/d/dr/drakej/apps/gpsapp/erts-6.4/../lib -env ERL_LIBS /afs/hcoop.net/user/d/dr/drakej/apps/gpsapp/lib -config /afs/hcoop.net/user/d/dr/drakej/apps/gpsapp/releases/0.0.1/sys.config -pa /afs/hcoop.net/user/d/dr/drakej/apps/gpsapp/lib/consolidated -args_file /afs/hcoop.net/user/d/dr/drakej/apps/gpsapp/releases/0.0.1/vm.args -user Elixir.IEx.CLI -extra --no-halt +iex -- console
> > Root: /afs/hcoop.net/user/d/dr/drakej/apps/gpsapp
> > /afs/hcoop.net/user/d/dr/drakej/apps/gpsapp
> > {error_logger,{{2015,5,3},{22,30,43}},"Protocol: ~tp: register/listen error: ~tp~n",["inet_tcp",etimedout]}
> > {error_logger,{{2015,5,3},{22,30,43}},crash_report,[[{initial_call,{net_kernel,init,['Argument__1']}},{pid,<0.21.0>},{registered_name,[]},{error_info,{exit,{error,badarg},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,322}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]}},{ancestors,[net_sup,kernel_sup,<0.10.0>]},{messages,[]},{links,[#Port<0.138>,<0.18.0>]},{dictionary,[{longnames,true}]},{trap_exit,true},{status,running},{heap_size,610},{stack_size,27},{reductions,743}],[]]}
> > {error_logger,{{2015,5,3},{22,30,43}},supervisor_report,[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{name,net_kernel},{mfargs,{net_kernel,start_link,[['gpsapp at 127.0.0.1',longnames]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]}
> > {error_logger,{{2015,5,3},{22,30,43}},supervisor_report,[{supervisor,{local,kernel_sup}},{errorContext,start_error},{reason,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}},{offender,[{pid,undefined},{name,net_sup},{mfargs,{erl_distribution,start_link,

the call stack says that it couldn't start up distributed erlang (with
an implicit dependency on the port mapper daemon epmd ).

as you're naming the node distributed erlang is required, and this is
the reason for the nodistribution exit mesage coming back from
net_kernel:start_link.

I'm not sure why you'd want to start your elixir app as a console app
btw which would allow you to skip all the next painful steps completely.
As a general rule, running a BEAM app with the console accessible from
the internet is a no-no, so your best option is to try to run this
without name services, or at least lock it down a bit to localhost.

For that, I'd see about registering a custom epmd port and bind address
for epmd to use, using  ERL_EPMD_PORT & ERL_EPMD_ADDRESS [1][2], and
referring to the options to restrict the port range used by erlang as
well [3]. I do this with ELIXIR_ERL_OPTS OTOH you can specify most or
all of these in vm.args too now I think."exercise for reader".

ELIXIR_ERL_OPTS='-kernel inet_dist_listen_min 4370 inet_dist_listen_max
4400 +A 64 +K true -shutdown 5000 -smp auto -d +pc unicode +# 1024'

the new cuttlefish app from basho ends up being a very nice guide to all
these little knobs and tweaks [4].

HTH
Dave

[1]: http://www.erlang.org/doc/man/epmd.html
[2]:
http://serverfault.com/questions/235669/how-do-i-make-rabbitmq-listen-only-to-localhost
[3]: http://erlang.org/doc/man/kernel_app.html
[4]:
https://github.com/basho/cuttlefish/blob/develop/priv/erlang_vm.schema




More information about the HCoop-Help mailing list