<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
I have tried to make a minimal embedded Erlang system to use as a template.
However, when i start the system - even in embedded mode - I get an Erlang
shell prompt.
<p>The files involved are:
<p>test.erl:
<br>======
<br>-module(test).
<br>-behaviour(application).
<br>-export([hello_sayer/0, start/2, stop/1]).
<p>hello_sayer() ->
<br> io:put_chars("hello, world\n"),
<br> receive _ -> []
<br> end.
<p>start(Type, Args) ->
<br> io:put_chars("Application started\n"),
<br> P = spawn(test, hello_sayer, []),
<br> {ok, P, P}.
<p>stop(P) ->
<br> io:put_chars("Application has exited\n"),
<br> exit(P).
<p>test.app:
<br>=======
<br>{application, test,
<br> [{description, "A simple test application"},
<br> {vsn,
"1.0"},
<br> {id,
"Test"},
<br> {modules, [{test,"1.0"}]},
<br> {maxP, infinity},
<br> {maxT, infinity},
<br> {registered, []},
<br> {applications, [kernel, stdlib]},
<br> {included_applications, []},
<br> {env,
[]},
<br> {mod,
{test, []}},
<br> {start_phases, []}]}.
<p>test.rel:
<br>=====
<br>{release, {"test","1.0"}, {erts, "4.4"},
<br> [{test, "1.0", permanent},
<br> {kernel, "2.1.4", permanent},
<br> {stdlib, "1.5.2", permanent}]}.
<br>
<p>I make a boot script using systools:make_script() and start the system
using "erl -boot test -mode embedded -pz /home/jfk/test/ebin". The system
writes "Application started" and "hello, world" as expected but then a
beam shell prompt appears! I expected the system to wait forever (because
nothing is ever sent to the started process). What am I doing wrong? How
can I make a minimal system which can be started from a Unix shell, write
something to standard output and then exit to the Unix shell?
<pre>--
Jørgen Frøjk Kjærsgaard, Systemkonsulent (Systems Consultant)
Informaticon ApS * Nørrevænget 143 * DK-8310 Tranbjerg J
Tlf: 8672 0093 * E-mail: jfk@informaticon.dk * <A HREF="http://www.informaticon.dk">http://www.informaticon.dk</A></pre>
</html>