Sample to upgrade slim release
Shell
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
generate.sh
rebar
reltool.config.v1
reltool.config.v2
sample.app.src.v2
sample_app.erl.v2
upgrade.sh

README.md

Sample to upgrade slim release, a little workaround needed

In upgrading, we need unpack relup archive manually and use release_handler:set_unpacked/2 directly.

cf: [erlang-bugs] release_handler error in upgrading slim release http://erlang.org/pipermail/erlang-bugs/2013-November/003900.html (Thanks to Siri Hansen!)

Environment:

Step 1

Generate version 1 and 2 of releases and upgrade package between them. The script generate.sh does this work with help of rebar. After the script finishes, the node with version 1 release is located at sample/rel/sample_1. Also the node with the version has started, whose name is sample@127.0.0.1.

Step 2

If we use release_handler:unpack_release/1 directly, an error happens (at least with R16B02):

(sample@127.0.0.1)1> release_handler:unpack_release("sample_2").
{error,{enoent,"/tmp/slim-upgrade-sample/sample/rel/sample_1/releases/sample_2.rel"}}

Steps for workaround is as follows:

  1. Unpack the relup archive, which is generated at Step 1, manually and place releases and new versions of applications to appropriate directories.
  2. Call release_handler:set_unpacked("releases/sample_2.rel", [{sample, "2", "lib"}]). manually.
  3. Call release_handler:install_release("2")..

All these steps are executed by the script upgrade.sh. After upgrading, we can confirm that new version is working by calling sample_app:new_export() which is a new function in version 2.

For full details, see upgrade.sh.

Some observations on release_handler:unpack_release/1

Look into lib/sasl/src/release_handler.erl https://github.com/erlang/otp/blob/OTP_R16B02/lib/sasl/src/release_handler.erl