Configurazione delle release e script di avvio
Padroneggi sys.config e gli script di avvio per configurare gli ambienti applicativi e controllare l'esatta sequenza di avvio di una release Erlang.
Configurazione delle release e script di avvio è 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 Release Configuration?
A release bundles your applications, the Erlang runtime, and configuration. Two files drive runtime behaviour: sys.config for application settings and the boot script for the startup sequence.
The Application Environment
Each OTP application has an environment — a set of key/value parameters. You read them at runtime with application:get_env/2.
application:get_env(my_app, port).sys.config Structure
sys.config is a single Erlang term: a list of {App, [{Key, Value}]} tuples that override application defaults at boot.
[
{my_app, [{port, 8080}, {pool_size, 10}]},
{kernel, [{logger_level, info}]}
].Overriding Defaults
Values in sys.config override those in each app .app file. This lets one codebase run differently per environment (dev, staging, prod) just by swapping config.
Reading Config at Runtime
Inside a gen_server init, pull configured values so behaviour follows the environment.
init([]) ->
{ok, Port} = application:get_env(my_app, port),
{ok, listen(Port)}.What Is a Boot Script?
The boot script (.script compiled to .boot) lists every application and module to load, and the order to start them. The runtime follows it to bring the system up deterministically.
Generated from the .rel File
You describe a release in a .rel file. Tools like systools or rebar3 turn it into the boot script.
{release,
{"my_system", "1.0.0"},
{erts, "13.0"},
[{kernel, "8.0"}, {stdlib, "4.0"}, {my_app, "1.0.0"}]}.Start Phases
Applications start in dependency order. If my_app lists kernel and stdlib as dependencies, the boot script guarantees they start first.
Permanent vs Temporary Apps
In the boot script an application can be permanent (its crash takes down the node), transient, or temporary. Choose permanent for core services.
Layered Config with config/0
You can split configuration across files and merge them, or use runtime os:getenv/1 reads for secrets that should not live in sys.config.
init([]) ->
Url = os:getenv("DATABASE_URL"),
{ok, connect(Url)}.Applying a Custom Config File
At node startup you point to a config file with the -config flag, letting one release run with different settings just by swapping the file.
erl -config /etc/my_system/prod.config -boot my_systemQuick Check
Test your release configuration knowledge.
Recap
You learned how releases are configured and started:
sys.configsets the application environment per deployment- Read values with
application:get_env/2 - The
.relfile is compiled into a boot script - Boot scripts start applications in dependency order
- Use permanent apps for core services and env vars for secrets
Impara Erlang con un tutor IA — gratis
Scrivi ed esegui vero codice nel tuo browser, ricevi aiuto istantaneo da un tutor IA disponibile 24/7, e riprendi da dove hai lasciato sul web o nell'app.
- Corsi
- 12
- Lezioni
- 48
Domande Frequenti
La lezione «Configurazione delle release e script di avvio» è gratuita?
Sì — il testo completo di «Configurazione delle release e script di avvio» è 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 «Configurazione delle release e script di avvio»?
Padroneggi sys.config e gli script di avvio per configurare gli ambienti applicativi e controllare l'esatta sequenza di avvio di una release Erlang. 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 «Configurazione delle release e script di avvio»?
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
- Creazione di release Erlang
- Caricamento e aggiornamento a caldo del codice
- Versionamento e distribuzione delle release
- Configurazione delle release e script di avvio