Konfiguracja wydań i skrypty startowe
Opanuj sys.config i skrypty startowe, aby konfigurować środowiska aplikacji i kontrolować dokładną sekwencję uruchamiania wydania Erlanga.
Konfiguracja wydań i skrypty startowe to bezpłatna lekcja Erlang OTP: Distributed & Fault-Tolerant Systems Programming na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Erlang OTP: Distributed & Fault-Tolerant Systems Programming, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Erlang OTP: Distributed & Fault-Tolerant Systems Programming zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
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
Ucz się Erlang dzięki korepetycjom AI — za darmo
Pisz i uruchamiaj kod w przeglądarce, otrzymuj natychmiastową pomoc od korepetytora AI dostępnego 24/7 i kontynuuj naukę w sieci lub w aplikacji.
- Kursy
- 12
- Lekcje
- 48
Często zadawane pytania
Czy lekcja „Konfiguracja wydań i skrypty startowe” jest bezpłatna?
Tak — pełny tekst „Konfiguracja wydań i skrypty startowe” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Erlang OTP: Distributed & Fault-Tolerant Systems Programming, przejdź na CoddyKit PRO. Kurs Erlang OTP: Distributed & Fault-Tolerant Systems Programming zawiera 4 lekcji w sumie.
Co nauczysz się w „Konfiguracja wydań i skrypty startowe”?
Opanuj sys.config i skrypty startowe, aby konfigurować środowiska aplikacji i kontrolować dokładną sekwencję uruchamiania wydania Erlanga. Ćwiczysz Erlang OTP: Distributed & Fault-Tolerant Systems Programming z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Erlang OTP: Distributed & Fault-Tolerant Systems Programming?
Nie wymagamy żadnego doświadczenia. Erlang OTP: Distributed & Fault-Tolerant Systems Programming w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.
Ile czasu zajmuje lekcja „Konfiguracja wydań i skrypty startowe”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Erlang OTP: Distributed & Fault-Tolerant Systems Programming?
Tak. Każda lekcja Erlang OTP: Distributed & Fault-Tolerant Systems Programming zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Tworzenie wydań Erlanga
- Hot code loading i aktualizacje
- Wersjonowanie i wdrażanie wydań
- Konfiguracja wydań i skrypty startowe