1 System Principles
1.1 Starting the System
An Erlang runtime system is started with the command
erl:Erlang (BEAM) emulator version 5.2.3.5 [hipe] [threads:0] Eshell V5.2.3.5 (abort with ^G) 1>
erlunderstands a number of command line arguments, seeerl(1). A number of them are also described in this chapter.Application programs can access the values of the command line arguments by calling one of the functions
init:get_argument(Key), orinit:get_arguments(). Seeinit(3).1.2 Restarting and Stopping the System
The runtime system can be halted by calling
halt/0,1. Seeerlang(3).The module
initcontains function for restarting, rebooting and stopping the runtime system. Seeinit(3).init:restart() init:reboot() init:stop()Also, the runtime system will terminate if the Erlang shell is terminated.
1.3 Boot Scripts
1.3.1 Default Boot Script
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. A binary boot script file has the extension.boot.See
script(4)for a detailed description of the syntax and contents of the boot script.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.
Which of
start_cleanandstart_saslto use as default is decided by the user when installing Erlang/OTP usingInstall. The user is asked "Do you want to use a minimal system startup instead of the SASL startup". If the answer is yes, thenstart_cleanis used, otherwisestart_saslis used. A copy of the selected boot script is made, namedstart.boot.1.3.2 User-Defined Boot Scripts
It is sometimes useful or necessary to create a user-defined boot script. This is true especially when running Erlang in embedded mode, see Code Loading Strategy.
It is possible to write a boot script manually. The recommended way to create a boot script, however, is to generate the boot script from a release resource file
Name.rel, using the functionsystools:make_script/1,2. This requires that the source code is structured as applications according to the OTP design principles. (The program does not have to be started in terms of OTP applications but can be plain Erlang).Read more about
.relfiles in OTP Design Principles andrel(4).The binary boot script file
Name.bootis generated from the boot script fileName.scriptusing the functionsystools:script2boot(File).Start the runtime system using the command line flag
-boot:% erl -boot <Name>1.4 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 <Mode>Default mode is interactive.
- In embedded mode, all code is loaded during system start-up according to the boot script. (Code can also be loaded later by explicitly ordering the code server to do so).
- 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.
Initially, the code path consists of the current working directory and all object code directories under
ROOT/lib, whereROOTis the installation directory of Erlang/OTP. Directories can be namedName[-Vsn]and the code server, by default, chooses the directory with the highest version number among those which have the sameName. The-Vsnsuffix is optional. If anebindirectory exists under theName[-Vsn]directory, it is this directory which is added to the code path.The code path can be extended by using the command line flags
-pa Directoriesand-pz Directories. These will addDirectoriesto the head or end of the code path, respectively.The code server module
codecontains a number of functions for modifying and checking the search path, seecode(3).1.5 File Types
The following file types are defined in Erlang/OTP:
File Type File Name/Extension Documented in module .erlErlang Reference Manual include file .hrlErlang Reference Manual release resource file .relrel(4)application resource file .appapp(4)boot script .scriptscript(4)binary boot script .boot- configuration file .configconfig(4)application upgrade file .appupappup(4)release upgrade file reluprelup(4)File Types