Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add slim release support #7

Closed
tuncer opened this Issue · 1 comment

1 participant

@tuncer

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
fi
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

SLIM_ARGS="-boot_var RELTOOL_EXT_LIB $RUNNER_BASE_DIR/lib \
-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 \
\"$RUNNER_BASE_DIR/releases\"

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

TODO releases/RELEASES

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/experiment.app.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 .
.
./rebar.config
./src
./src/experiment_sup.erl
./src/experiment.app.src
./src/experiment_app.erl
./ebin
./ebin/experiment.app
./ebin/experiment_app.beam
./ebin/experiment_sup.beam
./rel
./rel/reltool.config
./rel/experiment
./rel/experiment/releases
./rel/experiment/releases/1
./rel/experiment/releases/1/start_clean.rel
./rel/experiment/releases/1/experiment.rel
./rel/experiment/releases/1/vm.args
./rel/experiment/releases/1/experiment.script
./rel/experiment/releases/1/start_clean.boot
./rel/experiment/releases/1/sys.config
./rel/experiment/releases/1/experiment.boot
./rel/experiment/releases/1/start_clean.script
./rel/experiment/releases/RELEASES
./rel/experiment/releases/start_erl.data
./rel/experiment/bin
./rel/experiment/bin/install_upgrade.escript
./rel/experiment/bin/experiment
./rel/experiment/bin/start_erl.cmd
./rel/experiment/bin/experiment.cmd
./rel/experiment/lib
./rel/experiment/lib/experiment-1
./rel/experiment/lib/experiment-1/ebin
./rel/experiment/lib/experiment-1/ebin/experiment.app
./rel/experiment/lib/experiment-1/ebin/experiment_app.beam
./rel/experiment/lib/experiment-1/ebin/experiment_sup.beam
./rel/experiment/erts-5.9.2
./rel/experiment/erts-5.9.2/bin
./rel/experiment/erts-5.9.2/bin/nodetool
./rel/experiment/erts-5.9.2/bin/erl
./rel/experiment/log
./rel/experiment/log/sasl
./rel/files
./rel/files/nodetool
./rel/files/install_upgrade.escript
./rel/files/erl
./rel/files/vm.args
./rel/files/experiment
./rel/files/start_erl.cmd
./rel/files/sys.config
./rel/files/experiment.cmd

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
\"/tmp/experiment/rel/experiment/releases\"
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>},
                       {name,alarm_handler},
                       {mfargs,{alarm_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 20-Aug-2012::11:32:18 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.36.0>},
                       {name,overload},
                       {mfargs,{overload,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 20-Aug-2012::11:32:18 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.34.0>},
                       {name,sasl_safe_sup},
                       {mfargs,
                           {supervisor,start_link,
                               [{local,sasl_safe_sup},sasl,safe]}},
                       {restart_type,permanent},
                       {shutdown,infinity},
                       {child_type,supervisor}]

=PROGRESS REPORT==== 20-Aug-2012::11:32:18 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.37.0>},
                       {name,release_handler},
                       {mfargs,{release_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=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().
[{experiment,[],"1"},
 {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().
[{"experiment","1",
  ["kernel-2.15.2","stdlib-1.18.2","sasl-2.2.1",
   "experiment-1","compiler-4.8.1","crypto-2.1",
   "hipe-3.9.1","tools-2.6.8"],
  permanent}]
3> code:root_dir().
"/usr/local/lib/erlang"
4> code:which(experiment_sup).
"/tmp/experiment/rel/experiment/lib/experiment-1/ebin/experiment_sup.beam"
5>
@tuncer

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

@tuncer tuncer closed this
@aszlig aszlig referenced this issue from a commit in headcounter/deployment
@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 <aszlig@redmoonstudios.org>
700e1f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.