appup(4)
appup(4) π
Erlang Module Definition β Application upgrade file
okay bestie, welcome to the manual page for appup. it's giving "application upgrade file" and it's literally the blueprint for upgrading or downgrading an app in a running system. no cap.
β¨ NAME β¨
appup β Application upgrade file
π DESCRIPTION π
The application upgrade file defines how an application is upgraded or downgraded in a running system. periodt.
This file is used by the functions in systools when generating a release upgrade file relup. so like, systools is the one reading it to cook up relup. π₯
π File Syntax π
bestie, this file is to be called Application.appup, where Application is the application name. It is to be located in the ebin directory for the application. iykyk.
The .appup file contains one single Erlang term, which defines the instructions used to upgrade or downgrade the application. The file has the following syntax:
{Vsn,
[{UpFromVsn, Instructions}, ...],
[{DownToVsn, Instructions}, ...]}.
Vsn = string()β Current application version.UpFromVsn = string() | binary()β An earlier application version to upgrade from. If it is a string, it is interpreted as a specific version number. If it is a binary, it is interpreted as a regular expression that can match multiple version numbers.DownToVsn = string() | binary()β An earlier application version to downgrade to. If it is a string, it is interpreted as a specific version number. If it is a binary, it is interpreted as a regular expression that can match multiple version numbers.Instructionsβ A list of release upgrade instructions, see Release Upgrade Instructions. It is recommended to use high-level instructions only. These are automatically translated to low-level instructions bysystoolswhen creating therelupfile.
To avoid duplication of upgrade instructions, it is allowed to use regular expressions to specify UpFromVsn and DownToVsn. To be considered a regular expression, the version identifier must be specified as a binary. For example, the following match all versions 2.1.x, where x is any number:
<<"2\\.1\\.[0-9]+">>
Notice that the regular expression must match the complete version string, so this example works for, for example, 2.1.1, but not for 2.1.1.1. π
π Release Upgrade Instructions π
Release upgrade instructions are interpreted by the release handler when an upgrade or downgrade is made. For more information, see Release Handling in OTP Design Principles.
A process is said to use a module Mod if Mod is listed in the Modules part of the child specification used to start the process, see supervisor. In the case of gen_event, an event manager process is said to use Mod if Mod is an installed event handler.
π¦ High-Level Instructions π¦
{update, Mod}
{update, Mod, supervisor}
{update, Mod, Change}
{update, Mod, DepMods}
{update, Mod, Change, DepMods}
{update, Mod, Change, PrePurge, PostPurge, DepMods}
{update, Mod, Timeout, Change, PrePurge, PostPurge, DepMods}
{update, Mod, ModType, Timeout, Change, PrePurge, PostPurge, DepMods}
Mod = atom()
ModType = static | dynamic
Timeout = int()>0 | default | infinity
Change = soft | {advanced,Extra}
Extra = term()
PrePurge = PostPurge = soft_purge | brutal_purge
DepMods = [Mod]
Synchronized code replacement of processes using module Mod.
All those processes are suspended using sys:suspend, the new module version is loaded, and then the processes are resumed using sys:resume.
Changeβ Defaults tosoftand defines the type of code change. If it is set to{advanced,Extra}, implemented processes usinggen_server,gen_fsm,gen_statem, orgen_eventtransform their internal state by calling the callback functioncode_change. Special processes call the callback functionsystem_code_change/4. In both cases, the termExtrais passed as an argument to the callback function.PrePurgeβ Defaults tobrutal_purge. It controls what action to take with processes executing old code before loading the new module version. If the value isbrutal_purge, the processes are killed. If the value issoft_purge,release_handler:install_release/1returns{error,{old_processes,Mod}}.PostPurgeβ Defaults tobrutal_purge. It controls what action to take with processes that are executing old code when the new module version has been loaded. If the value isbrutal_purge, the code is purged when the release is made permanent and the processes are killed. If the value issoft_purge, the release handler purges the old code when no remaining processes execute the code.DepModsβ Defaults to[]and defines other modules thatModis dependent on. In therelupfile, instructions for suspending processes usingModcome before instructions for suspending processes using modules inDepModswhen upgrading, and conversely when downgrading. In case of circular dependencies, the order of the instructions in theappupfile is kept.Timeoutβ Defines the time-out when suspending processes. If no value ordefaultis specified, the default value forsys:suspendis used.ModTypeβ Defaults todynamic. It specifies if the code is "dynamic", that is, if a process using the module spontaneously switches to new code, or if it is "static". When doing an advanced update and upgrade, the new version of a dynamic module is loaded before the process is asked to change code. When downgrading, the process is asked to change code before loading the new version. For static modules, the new version is loaded before the process is asked to change code, both in the case of upgrading and downgrading. Callback modules are dynamic.
update with argument supervisor is used when changing the start specification of a supervisor.
{load_module, Mod}
{load_module, Mod, DepMods}
{load_module, Mod, PrePurge, PostPurge, DepMods}
Mod = atom()
PrePurge = PostPurge = soft_purge | brutal_purge
DepMods = [Mod]
Simple code replacement of the module Mod.
For a description of PrePurge and PostPurge, see update above.
DepMods defaults to [] and defines which other modules Mod is dependent on. In the relup file, instructions for loading these modules come before the instruction for loading Mod when upgrading, and conversely when downgrading.
{add_module, Mod}
{add_module, Mod, DepMods}
Mod = atom()
DepMods = [Mod]
Loads a new module Mod.
DepMods defaults to [] and defines which other modules Mod is dependent on. In the relup file, instructions related to these modules come before the instruction for loading Mod when upgrading, and conversely when downgrading.
{delete_module, Mod}
{delete_module, Mod, DepMods}
Mod = atom()
Deletes a module Mod using the low-level instructions remove and purge.
DepMods defaults to [] and defines which other modules Mod is dependent on. In the relup file, instructions related to these modules come before the instruction for removing Mod when upgrading, and conversely when downgrading.
{add_application, Application}
{add_application, Application, Type}
Application = atom()
Type = permanent | transient | temporary | load | none
Adding an application means that the modules defined by the modules key in the .app file are loaded using add_module.
Type defaults to permanent and specifies the start type of the application. If Type = permanent | transient | temporary, the application is loaded and started in the corresponding way, see application. If Type = load, the application is only loaded. If Type = none, the application is not loaded and not started, although the code for its modules is loaded.
{remove_application, Application}
Application = atom()
Removing an application means that the application is stopped, the modules are unloaded using delete_module, and then the application specification is unloaded from the application controller.
{restart_application, Application}
Application = atom()
Restarting an application means that the application is stopped and then started again, similar to using the instructions remove_application and add_application in sequence. Note that, even if the application has been started before the release upgrade is performed, restart_application may only load it rather than start it, depending on the application's start type: If Type = load, the application is only loaded. If Type = none, the application is not loaded and not started, although the code for its modules is loaded.
π Low-Level Instructions π
{load_object_code, {App, Vsn, [Mod]}}
App = Mod = atom()
Vsn = string()
Reads each Mod from directory App-Vsn/ebin as a binary. It does not load the modules. The instruction is to be placed first in the script to read all new code from the file to make the suspend-load-resume cycle less time-consuming.
point_of_no_return
If a crash occurs after this instruction, the system cannot recover and is restarted from the old release version. The instruction must only occur once in a script. It is to be placed after all load_object_code instructions.
{load, {Mod, PrePurge, PostPurge}}
Mod = atom()
PrePurge = PostPurge = soft_purge | brutal_purge
Before this instruction occurs, Mod must have been loaded using load_object_code. This instruction loads the module. PrePurge is ignored. For a description of PostPurge, see the high-level instruction update earlier.
{remove, {Mod, PrePurge, PostPurge}}
Mod = atom()
PrePurge = PostPurge = soft_purge | brutal_purge
Makes the current version of Mod old. PrePurge is ignored. For a description of PostPurge, see the high-level instruction update earlier.
{purge, [Mod]}
Mod = atom()
Purges each module Mod, that is, removes the old code. Notice that any process executing purged code is killed.
{suspend, [Mod | {Mod, Timeout}]}
Mod = atom()
Timeout = int()>0 | default | infinity
Tries to suspend all processes using a module Mod. If a process does not respond, it is ignored. This can cause the process to die, either because it crashes when it spontaneously switches to new code, or as a result of a purge operation. If no Timeout is specified or default is specified, the default value for sys:suspend is used.
{resume, [Mod]}
Mod = atom()
Resumes all suspended processes using a module Mod.
{code_change, [{Mod, Extra}]}
{code_change, Mode, [{Mod, Extra}]}
Mod = atom()
Mode = up | down
Extra = term()
Okay so Mode defaults to up and it tells everyone whether this is an upgrade or a downgrade situation. This instruction sends a code_change system message to every process that's using a module Mod, by calling sys:change_code, and it passes Extra along as the argument. β¨
{stop, [Mod]}
Mod = atom()
This one stops all processes using a module Mod by calling supervisor:terminate_child/2. Bestie, this instruction hits different when the simplest way to change code is literally just to stop and restart the processes running that code. π
{start, [Mod]}
Mod = atom()
And start brings all those stopped processes back, using module Mod, by calling supervisor:restart_child/2. Reunited and it feels so good π«Ά
{sync_nodes, Id, [Node]}
{sync_nodes, Id, {M, F, A}}
Id = term()
Node = node()
M = F = atom()
A = [term()]
Heads up: apply(M, F, A) must return a list of nodes.
This instruction syncs up your release installation with other nodes β the way it works is every Node has to evaluate this command with the same Id. Your local node just sits there waiting for all the other nodes to evaluate the instruction before execution continues. If a node goes down? That's an unrecoverable error, and the local node is restarted from the old release. π
Also there is no time-out for this instruction, which means it can hang forever. Not a drill. π
{apply, {M, F, A}}
M = F = atom()
A = [term()]
This evaluates apply(M, F, A). Simple as that. But the timing matters a lot, so listen up:
- If the instruction shows up before the instruction
point_of_no_return, a failure is caught. Thenrelease_handler:install_release/1returns{error,{'EXIT',Reason}}, unless{error,Error}is thrown or returned β in that case it returns{error,Error}. - If the instruction shows up after the instruction
point_of_no_returnand the function call fails, the system is restarted. π³
restart_new_emulator
This instruction is the main character when the application ERTS, Kernel, STDLIB, or SASL gets upgraded. It shuts down the current emulator and starts a brand new one. All processes are terminated gracefully, and the new version of ERTS, Kernel, STDLIB, and SASL are used when the emulator restarts. β¨
Rules, because of course there are rules:
- Only one
restart_new_emulatorinstruction is allowed in the relup file, and it must be placed first. systools:make_relup/3,4ensures this when the relup file is generated.- The rest of the instructions in the relup file is executed after the restart, as a part of the boot script.
An info report is written when the upgrade is completed. If you wanna know programmatically whether the upgrade is complete, call release_handler:which_releases/0,1 and check if the expected release has status current.
And ngl, the new release must still be made permanent after the upgrade is completed β otherwise the old emulator is started if there is an emulator restart. π
WARNING: As stated earlier, instruction restart_new_emulator causes the emulator to be restarted with new versions of ERTS, Kernel, STDLIB, and SASL. However, all other applications do at startup run their old versions in this new emulator. This is usually no problem, but every now and then incompatible changes occur to the core applications, which can cause trouble in this setting. Such incompatible changes (when functions are removed) are normally preceded by a deprecation over two major releases. To ensure that your application is not crashed by an incompatible change, always remove any call to deprecated functions as soon as possible. π§
restart_emulator
This instruction is similar to restart_new_emulator, except it must be placed at the end of the relup file. It is not related to an upgrade of the emulator or the core applications, but it can be used by any application when a complete reboot of the system is required. π₯
When generating the relup file, systools:make_relup/3,4 ensures that there is only one restart_emulator instruction and that it is the last instruction in the relup file.
π SEE ALSO π
release_handlerrelup(4)supervisorsystools
That's the whole vibe, bestie β every last instruction, delivered with love π This page was brought to you by Ericsson AB, hanging out with sasl 4.4, and it's literally called appup(4). Go slay your upgrades, and remember: make it permanent or it didn't happen. ππ¦π
π¦ where this page comes from
- arch rolling: erlang-core 29.1.1-1 Β· Apache-2.0
- nixos 26.05: erlang 29.1.2
- nixpkgs unstable: erlang 29.1.2
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms