script(4)

πŸ“¦
version 29.1.1 Β· 3 versions
, in arch rolling, nixos 26.05, nixpkgs unstable, ubuntu stonking

✨ NAME ✨

script β€” the Boot script, bestie πŸ’–


πŸŽ€ DESCRIPTION πŸŽ€

okay so listen. the boot script is literally the blueprint for how the Erlang runtime system wakes up and gets dressed in the morning. 🌸 it's got instructions in it for which code to load, and which processes and applications to start. it's giving "getting ready for the day" energy, but for a whole runtime system.

the command erl -boot Name starts the system with a boot file called Name.boot, and that file is generated from the Name.script file using systools:script2boot/1. ✨

and where does the .script file come from, you ask? it's generated by systools from a .rel file and from .app files. the whole pipeline is a whole vibe. πŸ’…

πŸ“„ File Syntax πŸ“„

the boot script lives in a file with extension .script, and it has this exact syntax:

{script, {Name, Vsn},
 [
  {progress, loading},
  {preLoaded, [Mod1, Mod2, ...]},
  {path, [Dir1,"$ROOT/Dir",...]}.
  {primLoad, [Mod1, Mod2, ...]},
  ...
  {kernel_load_completed},
  {progress, loaded},
  {kernelProcess, Name, {Mod, Func, Args}},
  ...
  {apply, {Mod, Func, Args}},
  ...
  {progress, started}]}.
  • Name = string() β€” defines the system name. that's the name, bestie. 🫢
  • Vsn = string() β€” defines the system version.
  • {progress, Term} β€” sets the "progress" of the initialization program. the init:get_status/0 function returns the current value of the progress, which is {InternalStatus,Term}. so it's how you peek at where the boot is at. ⭐
  • {path, [Dir]} β€” Dir is a string. this argument sets the load path of the system to [Dir]. the load path used to load modules is obtained from the initial load path, which is given in the script file, together with any path flags that were supplied in the command-line arguments. and the command-line arguments modify the path like this:
    • -pa Dir1 Dir2 ... DirN adds the directories DirN, DirN-1, ..., Dir2, Dir1 to the front of the initial load path. πŸ‘‘
    • -pz Dir1 Dir2 ... DirN adds the directories Dir1, Dir2, ..., DirN to the end of the initial load path.
    • -path Dir1 Dir2 ... DirN defines a set of directories Dir1, Dir2, ..., DirN, which replace the search path given in the script file. and directory names in the path are interpreted like this:
      • directory names starting with / are assumed to be absolute path names.
      • directory names not starting with / are assumed to be relative the current working directory.
      • the special $ROOT variable can only be used in the script, not as a command-line argument. the given directory is relative the Erlang installation directory.
  • {primLoad, [Mod]} β€” loads the modules [Mod] from the directories specified in Path. the script interpreter fetches the appropriate module by calling erl_prim_loader:get_file(Mod). and a fatal error that terminates the system occurs if the module cannot be located. 😭 no cap, that one's serious.
  • {kernel_load_completed} β€” indicates that all modules that must be loaded before any processes are started are loaded. in interactive mode, all {primLoad,[Mod]} commands interpreted after this command are ignored, and these modules are loaded on demand. in embedded mode, kernel_load_completed is ignored, and all modules are loaded during system start. two modes, two completely different behaviors, iconic. πŸ’…
  • {kernelProcess, Name, {Mod, Func, Args}} β€” starts the "kernel process" Name by evaluating apply(Mod, Func, Args). the start function is to return {ok, Pid} or ignore. the init process monitors the behavior of Pid and terminates the system if Pid dies. kernel processes are key components of the runtime system. and heads up: users do not normally add new kernel processes. like, that's not your lane bestie. 🚫
  • {apply, {Mod, Func, Args}}. β€” the init process evaluates apply(Mod, Func, Args). the system terminates if this results in an error. and the boot procedure hangs if this function never returns. πŸ’€
NOTE: in an interactive system, the code loader provides demand-driven code loading, but in an embedded system the code loader loads all code immediately. the same version of code is used in both cases. the code server calls init:get_argument(mode) to determine if it is to run in demand mode or non-demand driven mode.

πŸ¦‹ See Also πŸ¦‹

  • systools

and that's the whole page, bestie! this one came from Ericsson AB, it's sasl version 4.4, and it's the script(4) page. periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from