0Pricing
Erlang OTP: Distributed & Fault-Tolerant Systems Programming · レッスン

リリース設定とブートスクリプト

sys.configとブートスクリプトを使いこなし、アプリケーション環境を設定してErlangリリースの正確な起動順序を制御します。

「リリース設定とブートスクリプト」はCoddyKit上の無料Erlang OTP: Distributed & Fault-Tolerant Systems Programmingレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはErlang OTP: Distributed & Fault-Tolerant Systems Programming学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Erlang OTP: Distributed & Fault-Tolerant Systems Programmingコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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_system

Quick Check

Test your release configuration knowledge.

Recap

You learned how releases are configured and started:

  • sys.config sets the application environment per deployment
  • Read values with application:get_env/2
  • The .rel file is compiled into a boot script
  • Boot scripts start applications in dependency order
  • Use permanent apps for core services and env vars for secrets

よくある質問

「リリース設定とブートスクリプト」レッスンは無料ですか?

はい。「リリース設定とブートスクリプト」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Erlang OTP: Distributed & Fault-Tolerant Systems Programmingコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Erlang OTP: Distributed & Fault-Tolerant Systems Programmingコースには全4レッスンが含まれています。

「リリース設定とブートスクリプト」で何を学びますか?

sys.configとブートスクリプトを使いこなし、アプリケーション環境を設定してErlangリリースの正確な起動順序を制御します。 ブラウザで直接実行するハンズオンコードでErlang OTP: Distributed & Fault-Tolerant Systems Programmingを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Erlang OTP: Distributed & Fault-Tolerant Systems Programmingを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのErlang OTP: Distributed & Fault-Tolerant Systems Programmingは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「リリース設定とブートスクリプト」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このErlang OTP: Distributed & Fault-Tolerant Systems Programmingレッスンでコードを書いて実行できますか?

はい。すべてのErlang OTP: Distributed & Fault-Tolerant Systems Programmingレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. Erlangリリースの作成
  2. ホットコードローディングとアップグレード
  3. リリースのバージョン管理とデプロイ
  4. リリース設定とブートスクリプト
← Erlang OTP: Distributed & Fault-Tolerant Systems Programmingに戻る