erlangstudy4
Erlang Study – System Principles
- Origin: Getting Started With Erlang
- See also:
Restarting and Stopping the System
The module init contains function for restarting, rebooting and stopping the runtime system.init:restart() init:reboot() init:stop()
Boot Scripts
The runtime system is started using a boot script. The boot script contains instructions on which code to load and which processes and applications to start. A boot script file has the extension .script . The runtime system uses a binary version of the script. This binary boot script file has the extension .boot . Which boot script to use is specified by the command line flag -boot . The extension .boot should be omitted. Example, using the boot script start_all.boot :% erl -boot start_all
If no boot script is specified, it defaults to ROOT/bin/start .
Default Boot Scripts
Erlang/OTP comes with two boot scripts:
- start_clean.boot – Loads the code for and starts the applications Kernel and STDLIB.
- start_sasl.boot – Loads the code for and starts the applications Kernel, STDLIB and SASL.
A copy of the selected boot script is placed in the ROOT/bin directory, named start.boot .
Code Loading Strategy
The runtime system can be started in either embedded or interactive mode. Which one is decided by the command line flag -mode .% erl -mode embeddedDefault mode is interactive .
- In embedded mode, all code is loaded during system start-up according to the boot script.
- In interactive mode , code is dynamically loaded when first referenced . When a call to a function in a module is made, and the module is not loaded, the code server searches the code path and loads the module into the system.
% erl -pa /home/erl/mycode