Reputation: 10764
I'm working on a project that deals heavily with OTP releases and their upgrade process. I managed to perform hot upgrades from a release upgrade archive (tar.gz) using release_handler functions unpack_release, install_release and make_permanent. They are all invoked in the very node that is being upgraded.
Now I have to deal with a situation where the erlang node is down and I have to do an "offline" upgrade. Essentially what I want to achieve is to unpack release, and update certain files like RELEASES and start_erl.data (maybe some more?) so they are in the same state as they would be after a hot upgrade. The result would be that when the node is started, newly installed erlang release is booted. Also, an important thing is that I want to avoid running old release.
Any ideas how to do this as simple and cleanly as possible?
Upvotes: 3
Views: 671
Reputation: 757
Start an erlang node to get a shell. There is no need for a node name just be sure you are running the same ~/bin/erl
that the target node does. Then place your release package in ~/lib/erlang/releases
and unpack as you would normally:
1> application:start(sasl),
1> release_handler:unpack_release("my_release-1.0").
{ok, "1.0"}.
Now quit, shutting down the shell:
2> q().
[Don't try and cheat by using another window here! You must quit.]
Now you need to edit the ~/lib/erlang/releases/RELEASES
file and change the status of the new release from unpacked
to current
:
[{release,"My Release Package","1.0","5.9.1",
[{kernel,"2.15.1","/Users/otpuser/lib/erlang/lib/kernel-2.15.1"},
{stdlib,"1.18.1","/Users/otpuser/lib/erlang/lib/stdlib-1.18.1"},
{sasl,"2.2.1","/Users/otpuser/lib/erlang/lib/sasl-2.2.1"}, ...],
- unpacked}].
+ current}].
Start a shell again and make it permanent:
1> application:start(sasl),
1> release_handler:make_permanent("1.0").
ok
[Note: all that make_permanent/1
does is put the release version ("1.0"
) in ~/lib/erlang/releases/start_erl.data
so you could cheat here.]
Be sure to place your system configuration in ~/lib/erlang/releases/1.0/sys.config
.
Now when you run ~/bin/start
the release name will be read from start_erl.data
and init
will use the boot script in ~/lib/erlang/releases/1.0/start.boot
.
Upvotes: 3