Starting Erlang
Joe Armstrong
joe@REDACTED
Thu Apr 25 15:03:23 CEST 2002
On Thu, 25 Apr 2002, Ulf Wiger wrote:
> On Thu, 25 Apr 2002, Joe Armstrong wrote:
>
> > init.erl has the possibility to fetch code from the net.
> >
> > *does anybody use the -loader inet -hosts ...* stuff ?????
>
> We have at least discussed this option as we move towards running
> Erlang on our device boards. A simple NFS mount might do the
> trick, though. We need to look at it some more. Your idea of
> including binaries in the script file is a bit interesting, but
> it would make patching more difficult (then again, if it's an
> _option_, this doesn't have to be a problem).
I (quickly) tried changing eval_script in init.erl to include a command
to load some embedded code - a very easy change - this opens up
a range of interesting possibilities ...
assume the start.script is now
{script, {"OTP APN 181 01","P9"},
[{preLoaded,[init,erl_prim_loader]},
{progress,preloaded},
{loadCode, [sneaky]},
{apply, {sneaky, run, []}}]}
then you change systools:script2boot
so that is *expands* loadCode into
{script, {"OTP APN 181 01","P9"},
[{preLoaded,[init,erl_prim_loader]},
{progress,preloaded},
{loadCode, [{sneaky, <<Bin>>]},
{apply, {sneaky, run, []}}]}
Where Bin is the beam code for sneaky.erl
Now you define run() in sneaky.erl as
run() ->
init:eval_script([{path,["$ROOT/lib/kernel/ebin"]},
{primLoad,[application,
application_controller,
...
Or whatever :-) [It's not quite as simple as this
but you get the idea]
Once sneaky has terminated you get the old behaviour - *but* you can
embedd any code you like into the .boot file - so the complete
application can (if you like) be distributed as a single boot file, and to
run it you say
erl -boot BootFile
Since the bootfile can access the command line arguments, you can then
expand the system in an arbitrary manner
erl -boot Boot1 abc.ear ....
and then turn the whole thing into a single executable ...
/Joe
>
> Of course, _reading_ start.script would be a bit more tiring if
> all the beam code were embedded -- kindof defeats the purpose of
> having a text representation... I'm sure this can be solved
> elegantly.
>
> /Uffe
>
More information about the erlang-questions
mailing list