how to run misultin examples noninteractively
Fiedzia opened this issue · comments
This is probably due to my lack knowledge of erlang, but
Misultin examples work fine when i am running them from erl,
but fail when i am trying to invoke erl with -noshell:
make example;
cd examples
erl
Erlang R14B03 (erts-5.8.4) [source] [64-bit] [smp:6:6] [rq:6] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.8.4 (abort with ^G)
1> misultin_hello_world:start(8000).
{ok,<0.34.0>}
- this works
now when i try this:
erl -noshell -s misultin_hello_world start 8000
or this:
erl -noshell -eval "misultin_hello_world:start(8000)."
it doesn't throw any errors, but does not listen on given port.
Looks like there is something that erl does only when run interactively, but i have no ide what that could be.
Try running your noshell
example with the start_sasl boot script:
erl -noshell -boot start_sasl -s misultin_hello_world start 8000
You will find that 8000 is not treated as an integer but an atom: '8000'
In your other example, the problem is that misultin_hello_world:start/1
uses start_link
in order to link the resulting misultin top-level supervisor to the pid who calls it. In an example with the -eval
switch, the boot process doesn't live very long and thus tears misultin down due to the two-way link in place. An alternative example which demonstrates this:
erl -noshell -eval "spawn(fun() -> misultin_hello_world:start(8000), receive after 5000 -> ok end end)"
After 5 seconds (the timeout in the receive loop), the boot process will exit and tear down misultin with it. Because it is a normal exit, and misultin isn't configured as a top-level application, the emulator will keep running. That is why it's always a good idea to control your top-level application.
couldn't have argued better than skarab.
fiedzia, the erlang vm basically exits pretty quickly and thus you have nothing running there.
r.