Add slim release support #7

tuncer opened this Issue Nov 2, 2012 · 1 comment


None yet

1 participant

tuncer commented Nov 2, 2012

In R15B02 reltool gained an experimental "slim release" feature.
These are the TODO items for rebar and its release scripts.

An example shell session using the feature can be found at the end.

Pull request: #52.

TODO templatize or conditionalize release scripts

Either conditionalize or templatize release scripts (runner, nodetool, etc.)
to operate appropriately in slim release.

TODO detect slim mode

If reltool.config sys tuple has {excl_lib, otp_root}, slim release is enabled.
Use this as a detection method where needed.

TODO do not create unused erts-x.y.z directory in release

TODO runner script shared ERTS PATH

# Add ERTS bin dir to our path
ERL=$(which erl)
if [ ! -x "$ERL" ]; then
    echo "Failed to find erl. Is Erlang/OTP available in PATH?"
    exit 1
ERTS_PATH=$(dirname $ERL)
unset $ERL

TODO runner script killing node

Replace killing of PID of the process with the absolute path to the node's
beam[.smp] with a working alternative, because we're going to use the
global system ERTS and beam[.smp].

Basically, figure out how to get PID of beam spawned via run_erl -daemon
in runner script's 'start'/'start_boot' case. This is used to kill
a node which didn't stop via rpc:call with timeout=60000.

TODO runner script erl arguments

-sasl releases_dir $RUNNER_BASE_DIR/releases"

When starting:

erl -boot_var RELTOOL_EXT_LIB $RUNNER_BASE_DIR/lib -boot \
$RUNNER_BASE_DIR/releases/1/<nodeid> -sasl releases_dir \

Instead of supplying -sasl releases_dir <dir> we can also
put the same configuration in sys.config's sasl tuple.


The RELEASES file needs absolute paths and there is no resolution of
environment variables. The file is typically created at install time (i.e.
you never pack it and ship it), so there should be no need for this. After
first creation, RELEASES is read and altered by the release handler when
unpacking, installing or removing releases. It is not used for locating
files to load - that is a totally different mechanism.

The RELEASES file is the release_handler's persistent storage of
which releases are unpacked and/or installed on a target system, and which
state they have. It is updated each time a new release is unpacked,
installed or removed. The file that is created with create_RELEASES is the
initial version of this file. It should only exist on a real target system
and not in a release package. If we do not intend to use the
release_handler for upgrades, there is no need to create the RELEASES file.

We probably need a way to call releaser_handler:create_RELEASES for
the initial deployment and release_handler:set_unpacked for deploying
upgrades/downgrades. It's important to supply the right arguments to
differentiate $OTP_ROOT and $RELTOOL_EXT_LIB applications. Therefore we
may need a marker to detect it's a slim release we're working with.

TODO install_upgrade.escript

Adapt install_upgrade.escript to slim release changes.

Testing slim release support

$ cd /tmp
$ mkdir experiment
$ cd experiment/
$ rebar create-app appid=experiment
==> experiment (create-app)
Writing src/
Writing src/experiment_app.erl
Writing src/experiment_sup.erl
$ mkdir rel
$ cd rel/
$ rebar create-node nodeid=experiment
==> rel (create-node)
Writing reltool.config
Writing files/erl
Writing files/nodetool
Writing files/experiment
Writing files/sys.config
Writing files/vm.args
Writing files/experiment.cmd
Writing files/start_erl.cmd
Writing files/install_upgrade.escript

Edit reltool.config:

  • Add sys level {excl_lib,otp_root}
  • Add app level {lib_dir,".."} in app experiment
$ echo "{sub_dirs, [\"rel\"]}." > rebar.config
$ cat rebar.config
{sub_dirs, ["rel"]}.
$ cd ..
$ rebar compile generate
==> rel (compile)
==> experiment (compile)
Compiled src/experiment_sup.erl
Compiled src/experiment_app.erl
==> rel (generate)
$ find .

Start the node with the new release running on top of the shared OTP installation:

$ erl -boot_var RELTOOL_EXT_LIB /tmp/experiment/rel/experiment/lib -boot
/tmp/experiment/rel/experiment/releases/1/experiment -sasl releases_dir
Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:4:4] [async-threads:0]
[hipe] [kernel-poll:false]

=PROGRESS REPORT==== 20-Aug-2012::11:32:18 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.35.0>},

=PROGRESS REPORT==== 20-Aug-2012::11:32:18 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.36.0>},

=PROGRESS REPORT==== 20-Aug-2012::11:32:18 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.34.0>},

=PROGRESS REPORT==== 20-Aug-2012::11:32:18 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.37.0>},

=PROGRESS REPORT==== 20-Aug-2012::11:32:18 ===
         application: sasl
          started_at: nonode@nohost

=PROGRESS REPORT==== 20-Aug-2012::11:32:18 ===
         application: experiment
          started_at: nonode@nohost
Eshell V5.9.2  (abort with ^G)
1> application:which_applications().
 {sasl,"SASL  CXC 138 11","2.2.1"},
 {stdlib,"ERTS  CXC 138 10","1.18.2"},
 {kernel,"ERTS  CXC 138 10","2.15.2"}]
2> release_handler:which_releases().
3> code:root_dir().
4> code:which(experiment_sup).
tuncer commented Jan 16, 2013

@shino, thanks for the pull request. Closing the ticket.

@tuncer tuncer closed this Jan 16, 2013
@aszlig aszlig added a commit to headcounter/deployment that referenced this issue Jan 17, 2015
@aszlig aszlig rebar-nix.patch: Improve handling of reltool deps.
It's not any nicer than before, because dependencies are still cramped
together in one single store path, but at least it's _working_, so it's
better than nothing.

The implementation is done by simply appending to the lib_dirs option in
reltool.config at runtime.

As of rebar/rebar#7 there should also be support for slim releases,
which in our case would be preferable not only for OTP but _all_ of the
dependencies, so we're certainly aiming to use this.

Signed-off-by: aszlig <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment