1
<?xml version="1.0" encoding="latin1" ?>
2
<!DOCTYPE chapter SYSTEM "chapter.dtd">
7
<year>1996</year><year>2009</year>
8
<holder>Ericsson AB. All Rights Reserved.</holder>
11
The contents of this file are subject to the Erlang Public License,
12
Version 1.1, (the "License"); you may not use this file except in
13
compliance with the License. You should have received a copy of the
14
Erlang Public License along with this software. If not, it can be
15
retrieved online at http://www.erlang.org/.
17
Software distributed under the License is distributed on an "AS IS"
18
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19
the License for the specific language governing rights and limitations
24
<title>System Principles</title>
29
<file>system_principles.xml</file>
33
<title>Starting the System</title>
34
<p>An Erlang runtime system is started with the command <c>erl</c>:</p>
37
Erlang (BEAM) emulator version 5.2.3.5 [hipe] [threads:0]
39
Eshell V5.2.3.5 (abort with ^G)
41
<p><c>erl</c> understands a number of command line arguments, see
42
<c>erl(1)</c>. A number of them are also described in this
44
<p>Application programs can access the values of the command line
45
arguments by calling one of the functions
46
<c>init:get_argument(Key)</c>, or <c>init:get_arguments()</c>.
47
See <c>init(3)</c>.</p>
51
<title>Restarting and Stopping the System</title>
52
<p>The runtime system can be halted by calling <c>halt/0,1</c>.
53
See <c>erlang(3)</c>.</p>
54
<p>The module <c>init</c> contains function for restarting,
55
rebooting and stopping the runtime system. See <c>init(3)</c>.</p>
60
<p>Also, the runtime system will terminate if the Erlang shell is
65
<marker id="BOOTSCRIPT"></marker>
66
<title>Boot Scripts</title>
67
<p>The runtime system is started using a <em>boot script</em>.
68
The boot script contains instructions on which code to load and
69
which processes and applications to start.</p>
70
<p>A boot script file has the extension <c>.script</c>.
71
The runtime system uses a binary version of the script. This
72
<em>binary boot script</em> file has the extension <c>.boot</c>.</p>
73
<p>Which boot script to use is specified by the command line flag
74
<c>-boot</c>. The extension <c>.boot</c> should be omitted.
75
Example, using the boot script <c>start_all.boot</c>:</p>
77
% <input>erl -boot start_all</input></pre>
78
<p>If no boot script is specified, it defaults to
79
<c>ROOT/bin/start</c>, see Default Boot Scripts below.</p>
80
<p>The command line flag <c>-init_debug</c> makes the <c>init</c>
81
process write some debug information while interpreting the boot
84
% <input>erl -init_debug</input>
86
{progress,kernel_load_completed}
87
{progress,modules_loaded}
91
<p>See <c>script(4)</c> for a detailed description of the syntax
92
and contents of the boot script.</p>
95
<title>Default Boot Scripts</title>
96
<p>Erlang/OTP comes with two boot scripts:</p>
98
<tag><c>start_clean.boot</c></tag>
100
<p>Loads the code for and starts the applications Kernel and
103
<tag><c>start_sasl.boot</c></tag>
105
<p>Loads the code for and starts the applications Kernel,
109
<p>Which of <c>start_clean</c> and <c>start_sasl</c> to use as
110
default is decided by the user when installing Erlang/OTP using
111
<c>Install</c>. The user is asked "Do you want to use a minimal
112
system startup instead of the SASL startup". If the answer is
113
yes, then <c>start_clean</c> is used, otherwise
114
<c>start_sasl</c> is used. A copy of the selected boot script
115
is made, named <c>start.boot</c> and placed in
116
the <c>ROOT/bin</c> directory.</p>
120
<title>User-Defined Boot Scripts</title>
121
<p>It is sometimes useful or necessary to create a user-defined
122
boot script. This is true especially when running Erlang in
123
embedded mode, see <seealso marker="#code_loading">Code Loading Strategy</seealso>.</p>
124
<p>It is possible to write a boot script manually.
125
The recommended way to create a boot script, however, is to
126
generate the boot script from a release resource file
127
<c>Name.rel</c>, using the function
128
<c>systools:make_script/1,2</c>. This requires that the source
129
code is structured as applications according to the OTP design
130
principles. (The program does not have to be started in terms of
131
OTP applications but can be plain Erlang).</p>
132
<p>Read more about <c>.rel</c> files in OTP Design Principles and
134
<p>The binary boot script file <c>Name.boot</c> is generated from
135
the boot script file <c>Name.script</c> using the function
136
<c>systools:script2boot(File)</c>.</p>
141
<marker id="code_loading"></marker>
142
<title>Code Loading Strategy</title>
143
<p>The runtime system can be started in either <em>embedded</em> or
144
<em>interactive</em> mode. Which one is decided by the command
145
line flag <c>-mode</c>.</p>
147
% <input>erl -mode embedded</input></pre>
148
<p>Default mode is <c>interactive</c>.</p>
149
<list type="bulleted">
150
<item>In embedded mode, all code is loaded during system start-up
151
according to the boot script. (Code can also be loaded later
152
by explicitly ordering the code server to do so).</item>
153
<item>In interactive mode, code is dynamically loaded when first
154
referenced. When a call to a function in a module is made, and
155
the module is not loaded, the code server searches the code path
156
and loads the module into the system.</item>
158
<p>Initially, the code path consists of the current
159
working directory and all object code directories under
160
<c>ROOT/lib</c>, where <c>ROOT</c> is the installation directory
161
of Erlang/OTP. Directories can be named <c>Name[-Vsn]</c> and
162
the code server, by default, chooses the directory with
163
the highest version number among those which have the same
164
<c>Name</c>. The <c>-Vsn</c> suffix is optional. If an
165
<c>ebin</c> directory exists under the <c>Name[-Vsn]</c>
166
directory, it is this directory which is added to the code path.</p>
167
<p>The code path can be extended by using the command line flags
168
<c>-pa Directories</c> and <c>-pz Directories</c>. These will add
169
<c>Directories</c> to the head or end of the code path,
170
respectively. Example</p>
172
% <input>erl -pa /home/arne/mycode</input></pre>
173
<p>The code server module <c>code</c> contains a number of
174
functions for modifying and checking the search path, see
179
<title>File Types</title>
180
<p>The following file types are defined in Erlang/OTP:</p>
183
<cell align="left" valign="middle"><em>File Type</em></cell>
184
<cell align="left" valign="middle"><em>File Name/Extension</em></cell>
185
<cell align="left" valign="middle"><em>Documented in</em></cell>
188
<cell align="left" valign="middle">module</cell>
189
<cell align="left" valign="middle"><c>.erl</c></cell>
190
<cell align="left" valign="middle">Erlang Reference Manual</cell>
193
<cell align="left" valign="middle">include file</cell>
194
<cell align="left" valign="middle"><c>.hrl</c></cell>
195
<cell align="left" valign="middle">Erlang Reference Manual</cell>
198
<cell align="left" valign="middle">release resource file</cell>
199
<cell align="left" valign="middle"><c>.rel</c></cell>
200
<cell align="left" valign="middle"><c>rel(4)</c></cell>
203
<cell align="left" valign="middle">application resource file</cell>
204
<cell align="left" valign="middle"><c>.app</c></cell>
205
<cell align="left" valign="middle"><c>app(4)</c></cell>
208
<cell align="left" valign="middle">boot script</cell>
209
<cell align="left" valign="middle"><c>.script</c></cell>
210
<cell align="left" valign="middle"><c>script(4)</c></cell>
213
<cell align="left" valign="middle">binary boot script</cell>
214
<cell align="left" valign="middle"><c>.boot</c></cell>
215
<cell align="left" valign="middle">-</cell>
218
<cell align="left" valign="middle">configuration file</cell>
219
<cell align="left" valign="middle"><c>.config</c></cell>
220
<cell align="left" valign="middle"><c>config(4)</c></cell>
223
<cell align="left" valign="middle">application upgrade file</cell>
224
<cell align="left" valign="middle"><c>.appup</c></cell>
225
<cell align="left" valign="middle"><c>appup(4)</c></cell>
228
<cell align="left" valign="middle">release upgrade file</cell>
229
<cell align="left" valign="middle"><c>relup</c></cell>
230
<cell align="left" valign="middle"><c>relup(4)</c></cell>
232
<tcaption>File Types</tcaption>