0Pricing
Erlang OTP: Distributed & Fault-Tolerant Systems Programming · Lezione

Costruire applicazioni e release OTP

Raccolga i suoi GenServer e supervisor in una vera applicazione OTP e la includa in una release pronta per la distribuzione.

Costruire applicazioni e release OTP è una lezione Erlang OTP: Distributed & Fault-Tolerant Systems Programming gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Erlang OTP: Distributed & Fault-Tolerant Systems Programming, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Erlang OTP: Distributed & Fault-Tolerant Systems Programming include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

What Is an OTP Application?

An OTP application is a reusable component with a defined lifecycle: it starts, runs a supervision tree, and stops cleanly. It is the standard unit of packaging in Erlang.

The .app Resource File

Every application has an .app file describing its metadata: name, modules, dependencies, and the callback module that starts it.

{application, myapp,
 [{description, "My App"},
  {vsn, "1.0.0"},
  {modules, [myapp_app, myapp_sup]},
  {applications, [kernel, stdlib]},
  {mod, {myapp_app, []}}]}.

The application Behavior

The module named in mod implements the application behavior with start/2 and stop/1 callbacks.

-module(myapp_app).
-behaviour(application).
-export([start/2, stop/1]).

start/2

start/2 is called when the application launches. It starts the top supervisor and returns its pid.

start(_Type, _Args) ->
    myapp_sup:start_link().

stop/1

stop/1 is called on shutdown for cleanup. Often it simply returns ok.

stop(_State) ->
    ok.

Starting & Stopping

From the shell you can control applications at runtime.

application:start(myapp).
application:stop(myapp).

Application Environment

Configuration lives in the env section of the .app file and is read with application:get_env.

application:get_env(myapp, port).
% => {ok, 8080}

What Is a Release?

A release bundles your application, its dependencies, and a trimmed Erlang runtime into a single self-contained, deployable artifact.

Building with rebar3

The rebar3 build tool creates releases from a relx config in rebar.config.

{relx, [{release, {myapp, "1.0.0"}, [myapp]},
        {dev_mode, false},
        {include_erts, true}]}.

Running a Release

The generated release includes scripts to start, stop, and attach a console to the running node.

% rebar3 release
% _build/default/rel/myapp/bin/myapp foreground

Why Releases Matter

Releases give reproducible deployments: the exact runtime, app versions, and config travel together, and they support hot code upgrades, a hallmark of Erlang systems.

Quick Check

Test your OTP application knowledge.

Recap

You learned to package OTP code.

  • The .app file describes metadata and the start module
  • The application behavior provides start/2 and stop/1
  • Releases bundle app + runtime for reproducible deployment

Domande Frequenti

La lezione «Costruire applicazioni e release OTP» è gratuita?

Sì — il testo completo di «Costruire applicazioni e release OTP» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Erlang OTP: Distributed & Fault-Tolerant Systems Programming, passa a CoddyKit PRO. Il corso Erlang OTP: Distributed & Fault-Tolerant Systems Programming include 4 lezioni in totale.

Cosa imparerò in «Costruire applicazioni e release OTP»?

Raccolga i suoi GenServer e supervisor in una vera applicazione OTP e la includa in una release pronta per la distribuzione. Eserciti Erlang OTP: Distributed & Fault-Tolerant Systems Programming con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Erlang OTP: Distributed & Fault-Tolerant Systems Programming?

Non è richiesta alcuna esperienza precedente. Erlang OTP: Distributed & Fault-Tolerant Systems Programming su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.

Quanto tempo richiede la lezione «Costruire applicazioni e release OTP»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Erlang OTP: Distributed & Fault-Tolerant Systems Programming?

Sì. Ogni lezione Erlang OTP: Distributed & Fault-Tolerant Systems Programming include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Comprendere OTP e i behavior
  2. Implementazione del behavior GenServer
  3. Introduzione ai supervisor
  4. Costruire applicazioni e release OTP
← Torna a Erlang OTP: Distributed & Fault-Tolerant Systems Programming