Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates > by-pkgid > 675c8c8167236dfcf8d66da674f931e8 > files > 130

erlang-doc-R15B-03.3.fc17.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../otp_doc.css" type="text/css">
<title>Erlang -- System Principles</title>
</head>
<body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container">
<script id="js" type="text/javascript" language="JavaScript" src="../js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript">
            <!--
              function getWinHeight() {
                var myHeight = 0;
                if( typeof( window.innerHeight ) == 'number' ) {
                  //Non-IE
                  myHeight = window.innerHeight;
                } else if( document.documentElement && ( document.documentElement.clientWidth ||
                                                         document.documentElement.clientHeight ) ) {
                  //IE 6+ in 'standards compliant mode'
                  myHeight = document.documentElement.clientHeight;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                  //IE 4 compatible
                  myHeight = document.body.clientHeight;
                }
                return myHeight;
              }

              function setscrollpos() {
                var objf=document.getElementById('loadscrollpos');
                 document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2;
              }

              function addEvent(obj, evType, fn){
                if (obj.addEventListener){
                obj.addEventListener(evType, fn, true);
                return true;
              } else if (obj.attachEvent){
                var r = obj.attachEvent("on"+evType, fn);
                return r;
              } else {
                return false;
              }
             }

             addEvent(window, 'load', setscrollpos);

             //--></script><div id="leftnav"><div class="innertube">
<img alt="Erlang logo" src="../erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="../pdf/otp-system-documentation-5.9.3.1.pdf">PDF</a><br><a href="../index.html">Top</a></small><p><strong>System Principles</strong><br><strong>User's Guide</strong><br><small>Version 5.9.3.1</small></p>
<br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Chapters</strong></small></p>
<ul class="flipMenu" imagepath="../js/flipmenu">
<li id="loadscrollpos" title="System Principles" expanded="true">System Principles<ul>
<li><a href="system_principles.html">
              Top of chapter
            </a></li>
<li title="Starting the System"><a href="system_principles.html#id61981">Starting the System</a></li>
<li title="Restarting and Stopping the System"><a href="system_principles.html#id57021">Restarting and Stopping the System</a></li>
<li title="Boot Scripts"><a href="system_principles.html#id62035">Boot Scripts</a></li>
<li title="Code Loading Strategy"><a href="system_principles.html#id57401">Code Loading Strategy</a></li>
<li title="File Types"><a href="system_principles.html#id62064">File Types</a></li>
</ul>
</li>
<li id="no" title="Error Logging" expanded="false">Error Logging<ul>
<li><a href="error_logging.html">
              Top of chapter
            </a></li>
<li title="Error Information From the Runtime System"><a href="error_logging.html#id61881">Error Information From the Runtime System</a></li>
<li title="SASL Error Logging"><a href="error_logging.html#id61705">SASL Error Logging</a></li>
</ul>
</li>
<li id="no" title="Creating a First Target System" expanded="false">Creating a First Target System<ul>
<li><a href="create_target.html">
              Top of chapter
            </a></li>
<li title="Introduction"><a href="create_target.html#id61819">Introduction</a></li>
<li title="Creating a Target System"><a href="create_target.html#id62160">Creating a Target System</a></li>
<li title="Installing a Target System"><a href="create_target.html#id60978">Installing a Target System</a></li>
<li title="Starting a Target System"><a href="create_target.html#id62461">Starting a Target System</a></li>
<li title="System Configuration Parameters"><a href="create_target.html#id62658">System Configuration Parameters</a></li>
<li title="Differences from the Install Script"><a href="create_target.html#id62706">Differences from the Install Script</a></li>
<li title="Listing of target_system.erl"><a href="create_target.html#id62734">Listing of target_system.erl</a></li>
</ul>
</li>
</ul>
</div></div>
<div id="content">
<div class="innertube">
<h1>1 System Principles</h1>
  

  <h3><a name="id61981">1.1 
        Starting the System</a></h3>
    
    <p>An Erlang runtime system is started with the command <span class="code">erl</span>:</p>
    <div class="example"><pre>
% <span class="bold_code">erl</span>
Erlang (BEAM) emulator version 5.2.3.5 [hipe] [threads:0]

Eshell V5.2.3.5  (abort with ^G)
1&gt; </pre></div>
    <p><span class="code">erl</span> understands a number of command line arguments, see
      <span class="code">erl(1)</span>. A number of them are also described in this
      chapter.</p>
    <p>Application programs can access the values of the command line
      arguments by calling one of the functions
      <span class="code">init:get_argument(Key)</span>, or <span class="code">init:get_arguments()</span>.
      See <span class="code">init(3)</span>.</p>
  

  <h3><a name="id57021">1.2 
        Restarting and Stopping the System</a></h3>
    
    <p>The runtime system can be halted by calling <span class="code">halt/0,1</span>.
      See <span class="code">erlang(3)</span>.</p>
    <p>The module <span class="code">init</span> contains function for restarting,
      rebooting and stopping the runtime system. See <span class="code">init(3)</span>.</p>
    <div class="example"><pre>
init:restart()
init:reboot()
init:stop()</pre></div>
    <p>Also, the runtime system will terminate if the Erlang shell is
      terminated.</p>
  

  <h3><a name="id62035">1.3 
        Boot Scripts</a></h3>
    <a name="BOOTSCRIPT"></a>
    
    <p>The runtime system is started using a <strong>boot script</strong>.
      The boot script contains instructions on which code to load and
      which processes and applications to start.</p>
    <p>A boot script file has the extension <span class="code">.script</span>.
      The runtime system uses a binary version of the script. This
      <strong>binary boot script</strong> file has the extension <span class="code">.boot</span>.</p>
    <p>Which boot script to use is specified by the command line flag
      <span class="code">-boot</span>. The extension <span class="code">.boot</span> should be omitted.
      Example, using the boot script <span class="code">start_all.boot</span>:</p>
    <div class="example"><pre>
% <span class="bold_code">erl -boot start_all</span></pre></div>
    <p>If no boot script is specified, it defaults to
      <span class="code">ROOT/bin/start</span>, see Default Boot Scripts below.</p>
    <p>The command line flag <span class="code">-init_debug</span> makes the <span class="code">init</span>
      process write some debug information while interpreting the boot
      script:</p>
    <div class="example"><pre>
% <span class="bold_code">erl -init_debug</span>
{progress,preloaded}
{progress,kernel_load_completed}
{progress,modules_loaded}
{start,heart}
{start,error_logger}
...</pre></div>
    <p>See <span class="code">script(4)</span> for a detailed description of the syntax
      and contents of the boot script.</p>

    <h4>Default Boot Scripts</h4>
      
      <p>Erlang/OTP comes with two boot scripts:</p>
      <dl>
        <dt><strong><span class="code">start_clean.boot</span></strong></dt>
        <dd>
          <p>Loads the code for and starts the applications Kernel and
            STDLIB.</p>
        </dd>
        <dt><strong><span class="code">start_sasl.boot</span></strong></dt>
        <dd>
          <p>Loads the code for and starts the applications Kernel,
            STDLIB and SASL.</p>
        </dd>
      </dl>
      <p>Which of <span class="code">start_clean</span> and <span class="code">start_sasl</span> to use as
        default is decided by the user when installing Erlang/OTP using
        <span class="code">Install</span>. The user is asked "Do you want to use a minimal
        system startup instead of the SASL startup". If the answer is
        yes, then <span class="code">start_clean</span> is used, otherwise
        <span class="code">start_sasl</span> is used. A copy of the selected boot script
        is made, named <span class="code">start.boot</span> and placed in
        the <span class="code">ROOT/bin</span> directory.</p>
    

    <h4>User-Defined Boot Scripts</h4>
      
      <p>It is sometimes useful or necessary to create a user-defined
        boot script. This is true especially when running Erlang in
        embedded mode, see <span class="bold_code"><a href="#code_loading">Code Loading Strategy</a></span>.</p>
      <p>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
        <span class="code">Name.rel</span>, using the function
        <span class="code">systools:make_script/1,2</span>. 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).</p>
      <p>Read more about <span class="code">.rel</span> files in OTP Design Principles and
        <span class="code">rel(4)</span>.</p>
      <p>The binary boot script file <span class="code">Name.boot</span> is generated from
        the boot script file <span class="code">Name.script</span> using the function
        <span class="code">systools:script2boot(File)</span>.</p>
    
  

  <h3><a name="id57401">1.4 
        Code Loading Strategy</a></h3>
    <a name="code_loading"></a>
    
    <p>The runtime system can be started in either <strong>embedded</strong> or
      <strong>interactive</strong> mode. Which one is decided by the command
      line flag <span class="code">-mode</span>.</p>
    <div class="example"><pre>
% <span class="bold_code">erl -mode embedded</span></pre></div>
    <p>Default mode is <span class="code">interactive</span>.</p>
    <ul>
      <li>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).</li>
      <li>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.</li>
    </ul>
    <p>Initially, the code path consists of the current
      working directory and all object code directories under
      <span class="code">ROOT/lib</span>, where <span class="code">ROOT</span> is the installation directory
      of Erlang/OTP. Directories can be named <span class="code">Name[-Vsn]</span> and
      the code server, by default, chooses the directory with
      the highest version number among those which have the same
      <span class="code">Name</span>. The <span class="code">-Vsn</span> suffix is optional. If an
      <span class="code">ebin</span> directory exists under the <span class="code">Name[-Vsn]</span>
      directory, it is this directory which is added to the code path.</p>
    <p>The code path can be extended by using the command line flags
      <span class="code">-pa Directories</span> and <span class="code">-pz Directories</span>. These will add
      <span class="code">Directories</span> to the head or end of the code path,
      respectively. Example</p>
    <div class="example"><pre>
% <span class="bold_code">erl -pa /home/arne/mycode</span></pre></div>
    <p>The code server module <span class="code">code</span> contains a number of
      functions for modifying and checking the search path, see
      <span class="code">code(3)</span>.</p>
  

  <h3><a name="id62064">1.5 
        File Types</a></h3>
    
    <p>The following file types are defined in Erlang/OTP:</p>
    <table border="1" cellpadding="2" cellspacing="0">
<tr>
        <td align="left" valign="middle"><strong>File Type</strong></td>
        <td align="left" valign="middle"><strong>File Name/Extension</strong></td>
        <td align="left" valign="middle"><strong>Documented in</strong></td>
      </tr>
<tr>
        <td align="left" valign="middle">module</td>
        <td align="left" valign="middle"><span class="code">.erl</span></td>
        <td align="left" valign="middle">Erlang Reference Manual</td>
      </tr>
<tr>
        <td align="left" valign="middle">include file</td>
        <td align="left" valign="middle"><span class="code">.hrl</span></td>
        <td align="left" valign="middle">Erlang Reference Manual</td>
      </tr>
<tr>
        <td align="left" valign="middle">release resource file</td>
        <td align="left" valign="middle"><span class="code">.rel</span></td>
        <td align="left" valign="middle"><span class="code">rel(4)</span></td>
      </tr>
<tr>
        <td align="left" valign="middle">application resource file</td>
        <td align="left" valign="middle"><span class="code">.app</span></td>
        <td align="left" valign="middle"><span class="code">app(4)</span></td>
      </tr>
<tr>
        <td align="left" valign="middle">boot script</td>
        <td align="left" valign="middle"><span class="code">.script</span></td>
        <td align="left" valign="middle"><span class="code">script(4)</span></td>
      </tr>
<tr>
        <td align="left" valign="middle">binary boot script</td>
        <td align="left" valign="middle"><span class="code">.boot</span></td>
        <td align="left" valign="middle">-</td>
      </tr>
<tr>
        <td align="left" valign="middle">configuration file</td>
        <td align="left" valign="middle"><span class="code">.config</span></td>
        <td align="left" valign="middle"><span class="code">config(4)</span></td>
      </tr>
<tr>
        <td align="left" valign="middle">application upgrade file</td>
        <td align="left" valign="middle"><span class="code">.appup</span></td>
        <td align="left" valign="middle"><span class="code">appup(4)</span></td>
      </tr>
<tr>
        <td align="left" valign="middle">release upgrade file</td>
        <td align="left" valign="middle"><span class="code">relup</span></td>
        <td align="left" valign="middle"><span class="code">relup(4)</span></td>
      </tr>
</table>
<em>Table
        1.1:
         
        File Types</em>
  
</div>
<div class="footer">
<hr>
<p>Copyright © 1996-2012 Ericsson AB. All Rights Reserved.</p>
</div>
</div>
</div></body>
</html>