بناء تطبيقات OTP وإصداراتها
اجمع GenServers والمشرفين في تطبيق OTP حقيقي، ثم ضمّنه في إصدار قابل للنشر.
بناء تطبيقات OTP وإصداراتها درس مجاني في Erlang OTP: Distributed & Fault-Tolerant Systems Programming على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Erlang OTP: Distributed & Fault-Tolerant Systems Programming، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Erlang OTP: Distributed & Fault-Tolerant Systems Programming 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
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 foregroundWhy 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
.appfile describes metadata and the start module - The
applicationbehavior providesstart/2andstop/1 - Releases bundle app + runtime for reproducible deployment
الأسئلة الشائعة
هل درس «بناء تطبيقات OTP وإصداراتها» مجاني؟
نعم — نص درس «بناء تطبيقات OTP وإصداراتها» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Erlang OTP: Distributed & Fault-Tolerant Systems Programming، انتقل إلى CoddyKit PRO. تتضمن دورة Erlang OTP: Distributed & Fault-Tolerant Systems Programming 4 دروس في المجموع.
ماذا ستتعلم في «بناء تطبيقات OTP وإصداراتها»؟
اجمع GenServers والمشرفين في تطبيق OTP حقيقي، ثم ضمّنه في إصدار قابل للنشر. تتمرن على Erlang OTP: Distributed & Fault-Tolerant Systems Programming مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Erlang OTP: Distributed & Fault-Tolerant Systems Programming؟
لا تُشترط خبرة سابقة. Erlang OTP: Distributed & Fault-Tolerant Systems Programming على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «بناء تطبيقات OTP وإصداراتها»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Erlang OTP: Distributed & Fault-Tolerant Systems Programming هذا؟
نعم. كل درس في Erlang OTP: Distributed & Fault-Tolerant Systems Programming يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- فهم OTP والسلوكيات
- تنفيذ سلوك GenServer
- مقدمة إلى المشرفين
- بناء تطبيقات OTP وإصداراتها